Python,C,C++ and JAVA programs for CBSE, ISC, B.Tech and I.T Computer Science and MCA students

The Programming Project: Fibonacci Series in Python

Friday, April 18, 2014

Fibonacci Series in Python

#File: Fibonacci.py
#A simple program to generate Fibonacci series

def main():
    print "Fibonacci Series"
    n = input("Enter the value of n, number of terms:")
    x = n
    def fibo(n):
        if n == 0 or n == 1:
            return 1           
        else:
            return fibo(n-1)+fibo(n-2)
           
    for i in range(x+1):
        print fibo(i)   
main()

1 comment: