Post

Day 32 of 100 Days of Python

Practising Recursion

1
2
3
4
5
6
7
8
9
10
# Fibonacci Sequence

def fib(n):
    if n ==0:
        return 0
    if n==1:
        return 1
    return fib(n-1) + fib(n-2)
a = fib(5)
print(a)

 

This post is licensed under CC BY 4.0 by the author.

Trending Tags