1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
slava [35]
2 years ago
15

Write a iterative function that finds the n-th integer of the Fibonacci sequence. Then build a minimal program (main function) t

o test it. That is, write the fib() solution as a separate function and call it in your main() function to test it. For reference see Fibonacci number. INPUT OUTPUT (0, 2) (1, 3) (2, 5) 5 INPUT: OUTPUT: (0, 2) (1, 3) (2, 5) (3, 8) (4, 13) 13 INPUT: OUTPUT: (0, 2) 6765 (1, 3) (2, 5) (3, 8) (4, 13) (5, 21) (6, 34) (7, 55) (8, 89) (9, 144) (10, 233) Note, the first number in the pair is the iteration count (i) and the second number is the value of the (i+2)-th Fibonacci value. Problem 2 Write a recursive function that finds the n-th integer of the Fibonacci sequence. Then build a minimal program to test it. For reference see Fibonacci number. To check for recursion, please have the Fibonacci function print out its input as shown in the examples below: INPUT: OUTPUT: fib(5) fib(4) fib(3) fib(2) fib(1) fib(0) fib(1) fib(2) fib(1) fib(0) fib(3) fib(2) fib(1) INPUT: OUTPUT: fib(7) fib(6) fib(5) fib(4) fib(3) fib(2) fib(1) fib(0) fib(1) fib(2) fib(1) fib(0) fib(3) 13 Problem 3 In this problem, you need to print the pattern of the following form containing the numbers from 1 to n: 4 4 4 4 4 4 4 4 3 3 3 3 3 4 4 3 2 2 2 3 4 4 3 2 1 2 3 4 4 3 2 2 2 3 4 4 3 3 3 3 3 4 4 4 4 4 4 4 4 Example when n=4. INPUT Input contains a single integer n. CONSTRAINTS • 1 <= n <= 1000 OUTPUT Print the pattern mentioned in the problem statement. EXAMPLES: INPUT: INPUT: OUTPUT: 2 2 2 2 1 2 2 2 2 INPUT: 5 OUTPUT: 5 5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 4 5 5 4 3 3 3 3 3 4 5 5 4 3 2 2 2 3 4 5 5 4 3 2 1 2 3 4 5 5 4 3 2 2 2 3 4 5 5 4 3 3 3 3 3 4 5 5 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 INPUT: 7 INPUT: 7 OUTPUT: 7 7 7 7 7 7 7 7 7 7 7 7 7 7 6 6 6 6 6 6 6 6 6 6 6 7 7 6 5 5 5 5 5 5 5 5 5 6 7 7 6 5 4 4 4 4 4 4 4 5 6 7 7 6 5 4 3 3 3 3 3 4 5 6 7 7 6 5 4 3 2 2 2 3 4 5 6 7 7 6 5 4 3 2 1 2 3 4 5 6 7 7 6 5 4 3 2 2 2 3 4 5 6 7 7 6 5 4 3 3 3 3 3 4 5 6 7 7 6 5 4 4 4 4 4 4 4 5 6 7 7 6 5 5 5 5 5 5 5 5 5 6 7 7 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7
Engineering
2 answers:
Natasha2012 [34]2 years ago
7 0

Answer:

Codes for each of the problems are explained below

Explanation:

PROBLEM 1 IN C++:

#include<iostream>

using namespace std;

//fib function that calculate nth integer of the fibonacci sequence.

void fib(int n){

  // l and r inital fibonacci values for n=1 and n=2;

  int l=1,r=1,c;

 

  //if n==1 or n==2 then print 1.

  if(n==1 || n==2){

      cout << 1;

      return;

  }

  //for loop runs n-2 times and calculates nth integer of fibonacci sequence.

  for(int i=0;i<n-2;i++){

      c=l+r;

      l=r;

      r=c;

      cout << "(" << i << "," << c << ") ";

  }

  //prints nth integer of the fibonacci sequence stored in c.

  cout << "\n" << c;

}

int main(){

  int n; //declared variable n

  cin >> n; //inputs n to find nth integer of the fibonacci sequence.

  fib(n);//calls function fib to calculate and print fibonacci number.

}

PROBLEM 2 IN PYTHON:

def fib(n):

   print("fib({})".format(n), end=' ')

   if n <= 1:

       return n

   else:

       return fib(n - 1) + fib(n - 2)

if __name__ == '__main__':

   n = int(input())

   result = fib(n)

   print()

   print(result)

andre [41]2 years ago
6 0

You literally wrote gibberish so how do you expect us to answer this question. Even the other person who answered didn't know what he was talking about. :C

You might be interested in
Technician A says that the most commonly used combustion chamber types include hemispherical, and wedge. Technician B says that
Inessa05 [86]

Answer:

Technician A and Technician B both are correct.

Explanation:

Technician A accurately notes that perhaps the forms of combustion process most widely used are hemispherical and cross.

Technician B also correctly notes that in several cylinder heads, cooling system and greases gaps and pathways are found.

6 0
3 years ago
What type of engineer works to create a practical and safe energy source?
Fittoniya [83]
Why did you put this on here when you know the answer lol
4 0
3 years ago
A circular hoop sits in a stream of water, oriented perpendicular to the current. If the area of the hoop is doubled, the flux (
natka813 [3]

Answer:

The flux (volume of water per unit time) through the hoop will also double.

Explanation:

The flux = volume of water per unit time = flow rate of water through the hoop.

The Flow rate of water through the hoop is proportional to the area of the hoop, and the velocity of the water through the hoop.

This means that

Flow rate = AV

where A is the area of the hoop

V is the velocity of the water through the hoop

This flow rate = volume of water per unit time = Δv/Δt =Q

From all the above statements, we can say

Q = AV

From the equation, if we double the area, and the velocity of the stream of water through the hoop does not change, then, the volume of water per unit time will also double or we can say increases by a factor of 2

3 0
3 years ago
Six housing subdivisions within a city area are target for emergency service by a centralized fire station. Where should the new
Marina86 [1]

Answer:

Explanation:

Since there are six points, the minimum distance from all points would be the centroid of polygon formed by A,B,C,D,E,F

To find the coordinates of centroid of a polygon we use the following formula. Let A be area of the polygon.

C_{x}=\frac{1}{6A} sum(({x_{i} +x_{i+1})(x_{i}y_{i+1}-x_{i+1}y_{i}))     where i=1 to N-1 and N=6

C_{y}=\frac{1}{6A} sum(({y_{i} +y_{i+1})(x_{i}y_{i+1}-x_{i+1}y_{i}))

A area of the polygon can be found by the following formulaA=\frac{1}{2} sum(x_{i} y_{i+1} -x_{i+1} y_{i}) where i=1 to N-1

A=\frac{1}{2}[ (x_{1}  y_{2} -x_{2}  y_{1})+ (x_{2}  y_{3} -x_{3}  y_{2})+(x_{3}  y_{4} -x_{4}  y_{3})+(x_{4}  y_{5} -x_{5}  y_{4})+(x_{5}  y_{6} -x_{6}  y_{5})]

A=0.5[(20×25 -25×15) +(25×32 -13×25)+(13×21 -4×32)+(4×8 -18×21)+(18×14 -25×8)

A=225.5 miles²

Now putting the value of area in Cx and Cy

C_{x} =\frac{1}{6A}[ [(x_{1}+x_{2})(x_{1}  y_{2} -x_{2}  y_{1})]+ [(x_{2}+x_{3})(x_{2}  y_{3} -x_{3}  y_{2})]+[(x_{3}+x_{4})(x_{3}  y_{4} -x_{4}  y_{3})]+[(x_{4}+x_{5})(x_{4}  y_{5} -x_{5}  y_{4})]+[(x_{5}+x_{6})(x_{5}  y_{6} -x_{6}  y_{5})]]

putting the values of x's and y's you will get

C_{x} =15.36

For Cy

C_{y} =\frac{1}{6A}[ [(y_{1}+y_{2})(x_{1}  y_{2} -x_{2}  y_{1})]+ [(y_{2}+y_{3})(x_{2}  y_{3} -x_{3}  y_{2})]+[(y_{3}+y_{4})(x_{3}  y_{4} -x_{4}  y_{3})]+[(y_{4}+y_{5})(x_{4}  y_{5} -x_{5}  y_{4})]+[(y_{5}+y_{6})(x_{5}  y_{6} -x_{6}  y_{5})]]

putting the values of x's and y's you will get

C_{y} =22.55

So coordinates for the fire station should be (15.36,22.55)

5 0
2 years ago
Find the velocity and acceleration of box B when point A moves vertically 1 m/s and it is 5 m
Goshia [24]

Answer:

hshbdhehdjsbdjdissasoe

7 0
3 years ago
Other questions:
  • A pitfall cited in Section 1.10 is expecting to improve the overall performance of a computer by improving only one aspect of th
    6·1 answer
  • A computer maintenance company wants to 'capture' the knowledge that employees carry around in their heads by creating a databas
    5·1 answer
  • This is a new technology meant to reduce vehicle roll-overs A. Lane-departure warning B. Anti-lock brakes C. Inspection reports
    7·1 answer
  • In remote areas, your gps devices may lose reception. It’s a good idea to have a
    7·2 answers
  • What are the mechanical properties of a geotextile that are of most importance when using it as a separator in an unpaved road s
    12·1 answer
  • What parts do all circuits have in common?
    9·2 answers
  • (20 points) A 1 mm diameter tube is connected to the bottom of a container filled with water to a height of 2 cm from the bottom
    12·1 answer
  • A jointed arm robot can rotate on the following 6 axes?
    8·1 answer
  • Label each of the line types in the drawing below. ( will not mark you brainlest or whatever if you don't at least try to help)
    11·1 answer
  • Derive the expression ε=ln(1+e), where ε is the true strain and e is the engineering strain. Note that this expression is not va
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!