Loops · Python example
Multiply numbers in a loop to compute n! with a loop.
A factorial multiplies every positive integer up to n. The example uses an accumulator variable that grows on each iteration.
number = 6
result = 1
for value in range(2, number + 1):
result *= value
print(f"{number}! = {result}")