Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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, 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started