Python Program for Fibonacci Series

The Fibonacci series contains the numbers in the following integer sequence.

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ……..

Mathematically fibonacci series of numbers is defined by a recurrence relationship given below
Fn = Fn-1 + Fn-2
with starting values as
F0 = 0 and F1 = 1
Fibonacci series is a sequence where the next term is obtained by adding previous two terms. The first two terms of Fibonacci series are 0 and 1 as stated above.

Fibonacci Series Program in Python


# Function for nth Fibonacci number

def Fibonacci(n): 
    if n<0: 
        print("Please Enter Positive Number!") 
    elif n==1: 
        return 0
    elif n==2: 
        return 1
    else: 
        return Fibonacci(n-1)+Fibonacci(n-2) 

# Driver Program

# set the position to print nth
# fibonacci number

num = 12
print(Fibonacci(num))

# print a series of fibonacci numbers upto n

for i in range(1,num):
    print(Fibonacci(i))

Output:
13
Fibonacci Series is 
0
1
1
2
3
5
8
Related Programs
C program for Fibonacci series

Take a look at Fibonacci Numbers on Wikipedia for more details about fibonacci sequence.

Also have a look at this TEDTalk of Arthur Benjamin on Fibonacci Numbers.