Python Program to Find Factorial of a Number using For loop
ADVERTISEMENTS
Python program to find factorial of a number using for loop. In this article, you will learn how to make a python program to find factorial of a number using for loop.
Factorial Number Formula
Factorial of x (n!) = 1 * 2 * 3 * 4....n
Source Code
# Python Program to Find Factorial of a Number using For loop
print ("Enter an integer number to find the factorial::\n")
x, i, f = int(input()), 1, 1
# x - To store the input number
# f - To store the factorial value
if x > 0:
for i in range(1, x+1):
f *= i
print ("Factorial of ", x, " = ", f, "\n")
else:
print ("Sorry, The input number should be a positive number& it's greater than 0!\n")
Output
Enter an integer value to find the fact::
9
Factorial of 9 = 362880