Fibonacci Series in Python Using Recursion

(Last Updated On: 12/12/2022)

Python Program to Find the Fibonacci Series Using Recursion

# Fibonacci Series in Python Using Recursion

# Recursive function recur_fibo() is used
def recur_fibo(n):
   if n <= 1:
       return n
   else:
       return(recur_fibo(n-1) + recur_fibo(n-2))

num = 10

# check if the number of terms is valid
if num <= 0:
   print("Please enter a positive integer number")
else:
   print("Fibonacci Series:")
   
   # Use a for loop to iterate and calculate each term recursively
   for i in range(num):
       print(recur_fibo(i))

Output:

Fibonacci Series:
0
1
1
2
3
5
8
13
21
34

Leave a Reply

Your email address will not be published. Required fields are marked *