Question: 3. The Fibonacci sequence is 0, 1, 1, 2, 3, 5, 8, 13, 21, ... where the first two terms are 0 and 1, and

 3. The Fibonacci sequence is 0, 1, 1, 2, 3, 5,

3. The Fibonacci sequence is 0, 1, 1, 2, 3, 5, 8, 13, 21, ... where the first two terms are 0 and 1, and each term thereafter is the sum of the two preceding terms. Write a C++ program that repeatedly prompts for and reads a positive value n, calls a recursive function fibonnaci to calculate the nth number in the Fibonacci sequence, and then displays the number. For example, if n = 9, then the program would display 21. Here is the output from a sample run of the program (user input in bold): Fibonnaci number generator Which one do you want (negative to exit)? 4 The 4th Fibbonaci number is 2 Which one do you want (negative to exit)? 5 The 5th Fibbonaci number is 3 Which one do you want (negative to exit)? 6 The 6th Fibbonaci number is 5 Which one do you want (negative to exit)? 7 The 7th Fibbonaci number is 8 Which one do you want (negative to exit)? -1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!