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]
3 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]3 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]3 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
Machine movement can be divided into what two main categories?
pishuonlain [190]

Answer:

motion and power

Explanation:

8 0
3 years ago
Read 2 more answers
Compute the solution to x + 2x + 2x = 0 for Xo = 0 mm, vo = 1 mm/s and write down the closed-form expression for the response.
Nutka1998 [239]

Answer:

β = \frac{c}{\sqrt{km} } =  0.7071 ≈ 1 ( damping condition )

closed-form expression for the response is attached below

Explanation:

Given :  x + 2x + 2x = 0   for Xo = 0 mm and Vo = 1 mm/s

computing a solution :

M = 1,

c = 2,

k = 2,

Wn = \sqrt{\frac{k}{m} }  = \sqrt{2}  

next we determine the damping condition using the damping formula

β = \frac{c}{\sqrt{km} } =  0.7071 ≈ 1

from the condition above it can be said that the damping condition indicates underdamping

attached below is the closed form expression for the response

6 0
2 years ago
A 132mm diameter solid circular section​
Ganezh [65]

Answer:

not sure if this helps but

5 0
3 years ago
To increase the thermal efficiency of a reversible power cycle operating between thermal reservoirs at TH and Tc, would you incr
alukav5142 [94]

<u></u>\ T_{c} has greater effect.

<u>Explanation</u>:

\eta_{\max }=1-\frac{T_{c}}{T_{A}}

T_{c}\\ = Temperature of cold reservoir

T_{H} = Temperature of hot reservoir

when T_{c} is decreased by 't',

$\eta_{\text {incre }}$ = 1-\frac{\left(\tau_{c}-t\right)}{T_{H}}

=n \ + \frac{t}{T_{n}}      -(i)

when {T_{H}} is increased by 'T'

\eta_{i n c}=\frac{n+\frac{t}{T_{H}}}{\left(1+\frac{k}{T_{H}}\right)}-(ii)

\eta_{\text {incre }} \ T_{c}>\eta_{\text {incre }} T_{\text {H }}

7 0
3 years ago
How do I do this?<br> Blueprints, complete the missing view.
Ymorist [56]

Explanation:

Look at the drawings and decide which view is missing. Front? Side? Top? Then draw it

7 0
3 years ago
Other questions:
  • A simple ideal Rankine cycle with water as the working fluid operates between the pressure limits of 4 MPa in the boiler and 25
    14·2 answers
  • JAVA HADOOP MAPREDUCE
    13·1 answer
  • Overview In C, a string is simply an array of characters. We have used literal strings all along – the stuff in between the quot
    11·1 answer
  • Technician A says if the input signal turn-on time is too fast for the input circuit, your program may operate as though the inp
    11·1 answer
  • Compute the volume percent of graphite, VGr, in a 3.2 wt% C cast iron, assuming that all the carbon exists as the graphite phase
    8·1 answer
  • E xercise 17.1.2: For each of the transactions of Exercise 17.1.1, add the read- and write-actions to the computation and show t
    12·1 answer
  • Technician a says that diesel engines can produce more power because air in fuel or not mix during the intake stroke. Technician
    9·1 answer
  • Anything you want to do in Hootsuite can be found in the ________, with the main workspace in the _________?
    15·1 answer
  • (a) calculate the moment at point "c", where point "c" is the square 3'' below the centroid
    13·1 answer
  • Can I put a fork in electric socket?
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!