Day 24 - Recursion

Recursion in Python

Recursion is the process of defining something in terms of itself.

Python Recursive Function

In Python, we know that a function can call other functions. It is even possible for the function to call itself. These types of construct are termed as recursive functions.


def factorial(num): 
    if (num == 1 or num == 0):
        return 1
        return (num * factorial(num - 1)) 

# Driver Code 
num = 7; 
print("Number: ",num)
print("Factorial: ",factorial(num))


number:  7
Factorial:  5040