Program to find factorial in Python
Here, we are going to learn how to get the factorial of a number and display it.
Factorial of a positive integer is the multiplication of all integers smaller than or equal to n.
It is represented as n*(n-1)*(n-2)………….1
Example: 4! = 4*3*2*1 =24
- Input the number from user.
- Initialise the product variable to 1.
- Use the for loop ranging from 1 till n+1 in order to multiply and find the factorial.
- Print the factorial of the number.
n= int(input("Enter the number you want to find the factorial of: "))
for i in range(1,n+1):
Enter the number you want to find the factorial of: 5