Python Program to find factorial of a number using recursion
In this program, you will learn how to find factorial of a number using recursion in Python.
3! = 1 * 2 * 3
4! = 1 * 2 * 3 * 4
Example: How to find factorial of a number using recursion in Python.
def findfactorial(n):
if n == 0:
return 1
f = n * findfactorial(n - 1)
return f
n = int(input("Enter a number:"))
f = findfactorial(n)
print("Factorial is:", f)
Output:
Enter a number:5
Factorial is: 120