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

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz