Programming Examples
Python program to find the factorial value of given number
Write a Python program to accept a integer number form user and find the factorial value of input number.
The factorial of a number is the product of all the integers from 1 to that number. For example, the factorial of 6 is 1*2*3*4*5*6 = 720 . Factorial is not defined for negative numbers, and the factorial of zero is one, 0! = 1 .
Sample:
Input : 5
Output : 120
Solution
num=int(input("Enter any Number : "))
fact=1
for a in range(1,num+1):
fact=fact*a
print("Factorial of ",a," is : ",fact)
Output
Enter any Number : 5
Factorial of 5 is : 120