🚀 Hurry! Offer Ends In
00 Days
00 Hours
00 Mins
00 Secs
Enroll Now
X
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:

  1. Input: Reads an integer num from the user.
  2. Initialization: Sets factorial to 1.
  3. Calculation: Uses a loop to multiply factorial by each integer from 1 to num.
  4. Output: Prints the computed factorial.
 
Report an error

Meanwhile you can watch this video

Watch Video
Latest Updates