Question: The Fibonacci sequence is a sequence of numbers such that the first two numbers are 0 and 1, and each successive number is the sum
The Fibonacci sequence is a sequence of numbers such that the first two numbers are 0 and 1, and each successive number is the sum of the two previous numbers. Thus, here are the first nine numbers in the Fibonacci sequence:
0 1 1 2 3 5 8 13 21Â
The third number is 1 because the previous two numbers, 0 and 1, add up to 1. The fourth number is 2 because the previous two numbers, 1 and 1, add up to 2.
Provide a code fragment that prints the Fibonacci sequence numbers for the numbers less than 25 (i.e., the numbers shown above). Your code fragment must consist of just a for loop header terminated by a semicolon—nothing else. Use comma-separated initialization and update components. Feel free to use the following as a start for your for loop:
for (int m=0, n=1, temp;
By the way, we recommend that you avoid using code like this for your real programs. This exercise is just for fun (fun for a hacker, anyway ).
Step by Step Solution
3.41 Rating (148 Votes )
There are 3 Steps involved in it
for int m 0 n 1 temp m 25 temp m m n n temp Heres the completed for ... View full answer
Get step-by-step solutions from verified subject matter experts
