Important Notice:

Factorial of a Number

Factorial of a Number

13 views 1 min read
Program 8: Factorial of a Number
 
n = int(input("Enter a number: "))

fact = 1

for i in range(1, n + 1):
    fact = fact * i

print("Factorial =", fact)

Output:

Enter a number: 5
Factorial = 120

Calculation: 5 × 4 × 3 × 2 × 1 = 120

Related Notes