Python program to print the Fibonacci Series


Write a program in python to generate a list of elements of Fibonacci Series.

Note :- 

The Fibonacci Sequence is the series of numbers:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, …
The next number is found by adding up the two numbers before it:

Ex-
the 2 is found by adding the two numbers before it (1+1),
the 3 is found by adding the two numbers before it (1+2),
the 5 is (2+3),
and so on
---------------------------------

num=int(input("Enter the limit : "))
a=-1
b=1
for i in range(1,num+1):
    c=a+b
    print(c,end=' ')
    a=b
    b=c

---------------------------------

Output -

Enter the limit : 15

0 1 1 2 3 5 8 13 21 34 55 89 144 233 377

Post a Comment

0 Comments