Last Friday, I have done another quiz. The question is The Fibonacci numbers are members of an interesting sequence in which each number is equal to the sum of the previous two numbers. In the other words,
F1 = Fi-1 + Fi-2
where Fi refers to the ith Fibonacci number. By definition, the first two Fibonacci numbers equal 1; i.e:
F1 = F2 = 1.
Hence,
F3 = F2 + F1 = 1 + 1 = 2
F4 = F3 + F2 = 2 + 1 = 3
F5 = F4 + F3 = 3 + 2 = 5
and so on.
Write a program that will determine the first n Fibonacci numbers.
In this quiz, your tasks are:
1. to write the flowchart of the program in the next page.
2.to write, compile and debug your program to get required results.
Example output screen:
Enter a positive number : 15
The Fibonacci numbers are : 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610
Press any key to continue
I have done it but I didn't get the exactly answer. What I get is just till 377 only. Didn't reach the 610. I ask Dr.Zul about it and he explained.
Then this is my first result :
|
My result. |
|
|
Then the result. |
0 comments:
Post a Comment