Click here to Skip to main content
14,335,363 members
Rate this:
Please Sign up or sign in to vote.
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:

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

Rate this:
Please Sign up or sign in to vote.

Solution 1

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:
print(fibo(6))
   
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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100