Fibonacci Series Program in Python

Advertisements

Prev Tutorial Next Tutorial

Fibonacci Series Program in Python

You can write this program using for loop and while loop. Follow same concept like C programming only change syntax.

Fibonacci Series Program in Python

def fun(n):
   """Recursive function to
   print Fibonacci sequence"""
   if n <= 1:
       return n
   else:
       return(fun(n-1) + fun(n-2))

# receive input from the user
terms = int(input("How many terms U want Fibonacci ?: "))

if terms <= 0:
   print("Plese enter only positive integer")
else:
   print("Fibonacci Series:")
   for i in range(terms):
       print(fun(i))

Output

	
How many terms U want Fibonacci ?: 10
Fibonacci Series:
0
1
1
2
3
5
8
13
21
34

Prev Tutorial Next Tutorial

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements