python program for finding fibonacci series upto n numbers


#python program for finding fibonacci series upto n numbers  
#Alamgir Hossain, CSE, JUST

def fibo(n):
    if n<=1:
        return  n
    else:
        return  fibo(n-1)+fibo(n-2)

n = input("Enter the number : ")
print "Fibonacci series for ",n," numbers is : "
for i in range(0,n):
    print fibo(i)
     
    #----------Output-------------
    Enter the number : 5
    Fibonacci series for  5  numbers is :
    0
    1
    1
    2
    3

No comments:

Post a Comment