A Fibonacci sequence is a series of numbers that starts with a zero, followed by a one, and proceeds based on the rule that each number(called a Fibonacci number) is equal to the sum of the preceding two numbers.
0,1,1,2,3,5,8,13,21,34,…
•It starts with 0 & 1.
•The next number 1 is found by adding the two numbers before it(1+0).
•Similarly, the number 21 is found by adding the two numbers before it(13+8).
•And the number 34 from (21+13).
•And so on…
Here is the list
0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,
2584,4181,6765,10946,17711,28657,46368,75025,121393,
196418,317811,....
0,1,1,2,3,5,8,13,21,34,…
•It starts with 0 & 1.
•The next number 1 is found by adding the two numbers before it(1+0).
•Similarly, the number 21 is found by adding the two numbers before it(13+8).
•And the number 34 from (21+13).
•And so on…
Here is the list
0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,
2584,4181,6765,10946,17711,28657,46368,75025,121393,
196418,317811,....
Step2 :Let assign a variable a equal to -1 and b equal to 1
Step3 :We add variable a & b and assign it to variable x
Step4 :Display the value of x
Step5: Assign the value of b to variable a
Step6 :Assign the value of x to variable b
Step7 :Subtract one from n and store it to variable n
Step8 :if the value of n is not zero, go back to the third step
Step9 :Fibonacci numbers displayed till n numbers
To see the working of above algorithm,
Click here to Watch on YouTube
Step3 :We add variable a & b and assign it to variable x
Step4 :Display the value of x
Step5: Assign the value of b to variable a
Step6 :Assign the value of x to variable b
Step7 :Subtract one from n and store it to variable n
Step8 :if the value of n is not zero, go back to the third step
Step9 :Fibonacci numbers displayed till n numbers
To see the working of above algorithm,
Click here to Watch on YouTube
Comments
Post a Comment