Files
cybr108/lab-05/exercise-17.py
T
2026-10-12 17:48:57 -04:00

15 lines
385 B
Python

"""
Write a program to use a loop to find the factorial of a given number (e.g., 5!). The factorial of N is the product
of all integers from 1 to N.
"""
# Set input number and factorial variables
num = 5
factorial = 1
# Iterate through range of 1 to num var + 1 and multiply by i
for i in range(1, num + 1):
factorial = factorial * i
# Print resulting factorial
print(factorial)