+ 4

How can i create a recursive function of fibonacci series.

It was the last project in python core course. I did it simply with a normal function but i want to know how to do it with recursion. Plzz help🙏

5th Feb 2022, 3:08 AM
Shivansh Chauhan
Shivansh Chauhan - avatar
3 Réponses
+ 10
# Python program to display the Fibonacci sequence def recur_fibo(n): if n <= 1: return n else: return(recur_fibo(n-1) + recur_fibo(n-2)) nterms = 10 # check if the number of terms is valid if nterms <= 0: print("Plese enter a positive integer") else: print("Fibonacci sequence:") for i in range(nterms): print(recur_fibo(i))
6th Feb 2022, 1:04 AM
Vaibhav
Vaibhav - avatar
+ 4
https://code.sololearn.com/c5LuRi8oi7Ga/?ref=app Probably search through the list of codes first :)
5th Feb 2022, 3:13 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar