The Fibonacci numbers are defined by the sequence Reformulate that as fold 1 = 1; fold 2

Question:

The Fibonacci numbers are defined by the sequence
Reformulate that as
fold1 = 1;
fold2 = 1;
fnew = fold1 + fold2;
After that, discard fold2, which is no longer needed, and set fold2 to fold1 and fold1 to fnew. Repeat an appropriate number of times. Implement a program that prompts the user for an integer n and prints the nth Fibonacci number, using the above algorithm.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: