In This program going to take an input from user and finds the factorial of that number using a recursive function.
for example :-
Factorial of 6 = 6*5*4*3*2*1
Program to find factorial in Python
# Python Program to Find Factorial of Number
def factorial_num(number):
"""factorial_num is a recursive function that calls
itself to find the factorial of input number"""
if number == 1:
return number
else:
return number * factorial(number - 1)
# We will find the factorial of this number
number = int(input("Please Enter a Number: "))
if number < 0:
print("Factorial cannot be found for negative numbers ")
elif number == 0:
print("Factorial of number 0 is 1")
else:
print("Factorial of number ", number, "is: ", factorial(number))
Output:-
Please Enter a Number: 6 Factorial of number 6 is: 720