Python Tutorial for Beginners

Recursion and Recursive Function in Python

What is Recursion in Python?

The practice of defining something in terms of itself is known as recursion. Place two parallel mirrors facing each other in the physical world as an illustration. Any item between them would be recursively mirrored.

What is Python Recursive Function?

We know that a function in Python can call other functions. It's possible that the function will call itself. Recursive functions are the name for these types of constructs.


def factorial(x):

#This is a recursive function to find the factorial of an integer

    if x == 1:

        return 1


        return (x * factorial(x-1))

num = 3

print("The factorial of", num, "is", factorial(num))


The factorial of 3 is 6
Did you find this article helpful?