OneCompiler

Python program to print factorial of given number

984

Following program shows you how to print factorial of given number.
In this program we get number from user and prints factorial of that number using for loop

number = int(input("Enter a number:"))
result = 1
for i in range(1, number + 1):
	result = result * i
print(number, " factorial is: ", result)

Output:

Enter a number: 8
8  factorial is:  40320