Vivek Yadav
Vivek's blog


Vivek's blog


Day 24 - Recursion

Vivek Yadav's photo
Vivek Yadav
·Jan 30, 2023·

1 min read

Table of contents

  • Recursion in Python

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
Share this