Saturday, 13 May 2017

Fibonacci series using for loop

#Fibonacci series using for loop

#Asking user that how much terms he want in the fibonacci series
n=int(input("How much terms you want:"))

#displaying fibonacci terms
a,b=0,1
print("fib series=\n",1)
for i in range(1,n):
    s=a+b
    print(s)
    a,b=b,s

OUTPUT:

No comments:

Post a Comment