Python Program to find factorial of a number


In this program, You will learn how to find factorial of a number in Python.


3! = 1 * 2 * 3 => 6

4! = 1 * 2 * 3 * 4 => 24

Example: How to find factorial of a number in Python.

x = int(input("Enter a number:"))

f = 1
for i in range(1, x + 1):
    f = f * i

print("Factorial is:", f)

Output:

Enter a number:4
Factorial is: 24