Python program to Get Factorial Using Recursion

def factorial(x):
 if x == 1:
    return x
 return x * factorial(x-1)
y = int(input("Insert any number to calculate factorial: "))
print(factorial(y))

 

 

Output:

Insert any number to calculate factorial: 5
120

 

Insert any number to calculate factorial: 12
479001600

 

Subscribe For Daily Updates