- Input: Reads an integer
numfrom the user. - Initialization: Sets
factorialto 1. - Calculation: Uses a loop to multiply
factorialby each integer from 1 tonum. - Output: Prints the computed factorial.
Questions
Python Program to Find the Factorial of a positive Number
Last Updated : 23 May 2026
Jul 21, 22, 23, Jan 21, 24
Solution:
# Get an integer input from the user
num = int(input("Enter number: "))
# Initialize the factorial result to 1
factorial = 1
# Calculate the factorial using a loop
for i in range(1, num + 1):
factorial *= i # Multiply factorial by the current number
# Print the result
print("Factorial is =", factorial)
OUTPUT:
Enter number: 5
Factorial is = 120
Explanation:
Meanwhile you can watch this video
Watch Video