Python Program to find the Factorial of a number
Find a Factorial of a Number
Number is 8.
Factorial of a 8 = 40,320
Note:-Factorial of n number is 1*2*3*…n. You will learn to calculate the factorial of a number using for loop in this example.
Step 1.Read the number num.
Step 2.Initialize the variable factorial=1
Step 3.To take a user input for factorial of number
Step 4.We use for loop starts from 1 to num + 1.
Step 5.Then, Inside For loop factorial = factorial * i
Step 6.Print the variable of factorial.
num = int(input("Enter the number:")) factorial = 1 for i in range(1, num+1): factorial = factorial * i print("Factorial of a Given Number:", factorial) # This code is contributed by Shubhanshu Arya (Prepinsta Placement Cell Student)
Enter the number:5
Factorial of a Given Number: 120