Write a recursive function that accepts an integer argument and returns the factorial.

Source Code

def factorial(n):
    if n == 1:
        return 1
    else:
        return n * factorial(n-1)


#calling the factorial function
number = 5
print("The factorial of", number, "is", factorial(number))

Output

The factorial of 5 is 120