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
g A steel water pipe has an inner diameter of 12 in. and a wall thickness of 0.25 in. Determine the longitudinal and hoop stress
zvonat [6]

Answer:

a) \mathbf{\sigma _ 1 = 4800 psi}

     \mathbf{ \sigma _2 = 0}

b)\mathbf{\sigma _ 1 = 6000 psi}

  \mathbf{ \sigma _2 = 3000 psi}

Explanation:

Given that:

diameter d = 12 in

thickness t = 0.25 in

the radius = d/2 = 12 / 2 = 6 in

r/t = 6/0.25 = 24

24 > 10

Using the  thin wall cylinder formula;

The valve A is opened and the flowing water has a pressure P of 200 psi.

So;

\sigma_{hoop} = \sigma _ 1 = \frac{Pd}{2t}

\sigma_{long} = \sigma _2 = 0

\sigma _ 1 = \frac{Pd}{2t} \\ \\ \sigma _ 1 = \frac{200(12)}{2(0.25)}

\mathbf{\sigma _ 1 = 4800 psi}

b)The valve A is closed and the water pressure P is 250 psi.

where P = 250 psi

\sigma_{hoop} = \sigma _ 1 = \frac{Pd}{2t}

\sigma_{long} = \sigma _2 = \frac{Pd}{4t}

\sigma _ 1 = \frac{Pd}{2t} \\ \\ \sigma _ 1 = \frac{250*(12)}{2(0.25)}

\mathbf{\sigma _ 1 = 6000 psi}

\sigma _2 = \frac{Pd}{4t} \\ \\  \sigma _2 = \frac{250(12)}{4(0.25)}

\mathbf{ \sigma _2 = 3000 psi}

The free flow body diagram showing the state of stress on a volume element located on the wall at point B is attached in the diagram below

8 0
3 years ago
Why does teachers grade things that are not due yet​
pav-90 [236]
I think because if you’ve already turned it in they might as well grade asap instead of waiting
4 0
3 years ago
Read 2 more answers
Consider a multiprocessor system and a multithreaded program written using the many-to-many threading model. Let the number of u
Montano1993 [528]

Answer:

At the point when the quantity of bit strings is not exactly the quantity of processors, at that point a portion of the processors would stay inert since the scheduler maps just part strings to processors and not client level strings to processors. At the point when the quantity of part strings is actually equivalent to the quantity of processors, at that point it is conceivable that the entirety of the processors may be used all the while. Be that as it may, when a part string obstructs inside the portion (because of a page flaw or while summoning framework calls), the comparing processor would stay inert. When there are more portion strings than processors, a blocked piece string could be swapped out for another bit string that is prepared to execute, in this way expanding the use of the multiprocessor system.When the quantity of part strings is not exactly the quantity of processors, at that point a portion of the processors would stay inert since the scheduler maps just bit strings to processors and not client level strings to processors. At the point when the quantity of bit strings is actually equivalent to the quantity of processors, at that point it is conceivable that the entirety of the processors may be used at the same time. Be that as it may, when a part string hinders inside the piece (because of a page flaw or while summoning framework calls), the relating processor would stay inert. When there are more portion strings than processors, a blocked piece string could be swapped out for another bit string that is prepared to execute, along these lines expanding the usage of the multiprocessor framework.

4 0
3 years ago
Show the ERD with relational notation with crowfoot. Your ERD must show PK, FKs, min and max cardinality, and correct line types
zhenek [66]

Answer

The answer and procedures of the exercise are attached in the following archives.

Step-by-step explanation:

You will find the procedures, formulas or necessary explanations in the archive attached below. If you have any question ask and I will aclare your doubts kindly.  

3 0
3 years ago
Bending is defined as? A. the application of a load tending to distort a member in one direction. B. the application of opposing
amm1812
Hi how are you today
4 0
2 years ago
Other questions:
  • 4.71 A full-wave rectifier circuit with a 1-kΩ operates from a 120-V (rms) 60-Hz household supply through a 6-to-1 transformer h
    10·1 answer
  • Project 8:The Harris-Benedict equation estimates the number of calories your body needs to maintain your weight if you do no exe
    5·1 answer
  • What is the uncertainty in position of an electron of an atom if there is t 2.0 x 10' msec uncertainty in its velocity? Use the
    12·1 answer
  • Module 42 Review and Assessment
    7·1 answer
  • A soil element is subjected to a minor principle stress of 50 kPa on a plane rotated 20 ° counterclockwise from vertical. If the
    10·1 answer
  • A 75- kw, 3-, Y- connected, 50-Hz 440- V cylindrical synchronous motor operates at rated condition with 0.8 p.f leading. the mot
    6·1 answer
  • You must yield the right-of-way to all of the following EXCEPT:
    8·1 answer
  • 1)
    13·1 answer
  • A global resources company uses data-intensive, cloud-based simulation software, but users in remote locations find that the res
    6·1 answer
  • The thrust angle is checked by referencing
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!