Friday, February 13, 2015

Fibonacci number in python

def fibonnaci(n):
    ''' Identifying fibonnoaci value for the given number n '''
    if n <= 1:
        return n
    else:
        return fibonnaci(n - 1) + fibonnaci(n - 2)

number = int(raw_input('Enter the number of terms: '))
series = []
for i in range(number):
    series.append(fibonnaci(i))
for serie in series[::-1]:
    print serie

No comments:

Post a Comment