Exit
  1. Learn
  2. Check
  3. Solve
  4. Reflect

Multiply them all

Last time each pass added the counter to a total. A loop can do any job with the counter, and multiplying is just as common. The factorial of 5 means 5 times 4 times 3 times 2 times 1, and we write it 5!.

The pattern is the same: make a box before the loop, then update it on each pass. Only the update changes. Now it multiplies the box by the counter, instead of adding to it.

The loop shape stays the same, only the update changes.
In code
product = 1
for i in range(1, 6):
    product = product * i
Factorial of 5
1
0
2
1
3
2
4
3
5
4
i
i
1
product
1

The product starts at 1. Pass one multiplies it by 1, so it stays 1.

Move 1 of 5

Which number to start from

The starting number matters. A running total starts at 0, because adding zero changes nothing. A running product must start at 1, because multiplying by 1 changes nothing.

Start a product at 0 and every pass multiplies zero by something, so the answer stays 0 forever. Ask yourself: what value can I start with that doesn't change the result? That is the right starting number.

Start a total at 0. Start a product at 1.