Python Program to find fibonacci series

Program

num = int(input("Enter the range of fibonacci series:\t"))
first = 0
second = 1
i = 0
print("Fibonacci Series")
while(i < num):
    if(i <= 1):
        next = i
    else:
        next = first + second
        first = second
        second = next
    print(next,"\t",end="")
    i = i + 1
print()

Output

Enter the range of fibonacci series:	6
Fibonacci Series
0 	1 	1 	2 	3 	5

Tags: