Recursive Fibonacci sequence!


In [1]:
def fibo(n): 
    if n == 0:
        return 0
    elif n == 1:
        return 1
    return fibo(n-1) + fibo(n-2)

In [2]:
fibo(5)


Out[2]:
5

In [3]:
fibo(10)


Out[3]:
55

In [4]:
fibo(0)


Out[4]:
0

In [5]:
fibo(1)


Out[5]:
1

In [8]:
fibo(4)


Out[8]:
3