Program to calculate the factorial of a number

# Factorial of a Number
def factorial(n):
    if n == 0:
        return 1
    else:
        return n * factorial(n - 1)

num = int(input("Enter a number: "))
print("The factorial of", num, "is", factorial(num))
Output:
Enter a number: 5
The factorial of 5 is 120

Leave a Reply

Your email address will not be published. Required fields are marked *