Recursion Examples in Python

In this class, we discuss Recursion Examples in Python.

For Complete YouTube Video: Click Here

Recursion Examples

The reader should have prior knowledge of how the recursive function call will execute. And memory allocation to recursive functions. Click here.

Please check the program and solve it on your own for better practice.

Please follow the above video for a better understanding of the examples.

Program

def f(x):
    if x>0:
        f(x-1)
        f(x-2)
        print(x)
a=5
f(a)
Output:
1
2
1
3
1
2
4
1
2
1
3
5