You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calculate the nth Fibonacci number where n is a given positive number.
Fibonacci’s sequence is characterized by the fact that every number after the first two is the sum of the two preceding ones. For example, consider the following series:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, … and so on.
INPUT
7
OUTPUT
0 1 1 2 3 5 8 13
13
EXPLANATION
As we can see above, each subsequent number is the sum of the previous two numbers. The starting point of the sequence is sometimes considered 1, resulting in the first two numbers in the Fibonacci sequence as 1 and 1.