feat: completed exercise 17 and 18
This commit is contained in:
+11
-1
@@ -1,4 +1,14 @@
|
||||
"""
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user