Question: In C++ please, Write a program that computes the sequence of Fibonacci numbers. The formula for generating the next Fibonacci number is: Fn = Fn1
In C++ please,
Write a program that computes the sequence of Fibonacci numbers. The formula for generating the next Fibonacci number is: Fn = Fn1 + Fn2, where F1 = 1 and F2 = 2. For example, F3 = F2 + F1 = 2 + 1 = 3. You will notice that at some point Fibonacci numbers are too large and they do not fit in type int. This is called the integer overflow. When they become negative (or non-increasing), stop the program. Please use three different functions, one for each type.
How many Fibonacci numbers fit in type int? What is the value of the largest one?
How many Fibonacci numbers fit in type long? What is the value of the largest one?
How many Fibonacci numbers fit in type long long? What is the value of the largest one?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
