Click here to Skip to main content
15,882,152 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The question is to print a fibonacci series using recursion. I am not getting output for the following code (I use pyCharm for running codes).

What I have tried:

Python
def fibo(n):
    if n==0 or n==1:
        return 1
    else:
        return fibo(n-2)+fibo(n-1)


fibo(6)
Posted
Updated 6-Jul-19 5:00am

1 solution

The value is being calculated, but you are not doing anything with it - it's just getting discarded. You might want to print it on the console:
Python
print(fibo(6))
 
Share this answer
 
Comments
Member 14517556 6-Jul-19 11:23am    
Thank you.
CPallini 6-Jul-19 11:56am    
5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900