Header Ads Widget

python program to print the fibonacci series by iterative function.

 what is fibonacci series:- 

                                        In the fibonacci series every elements are the some of two elements before it.

Fibonacci Sequence = 0, 1, 1, 2, 3, 5, 8, 13, 21, ….

code:-


# function for finding fibbo
def fib(n):
first=0
second=1
if n<=1:
return n
for i in range(1,n):
next=first+second
first=second
second=next
return next


n=int(input("Enter number of term in series"))
for i in range(n):
print(fib(i),end=" ")

Output:-


Enter number of term in series6
0 1 1 2 3 5



Post a Comment

0 Comments