Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
The factorial of is . Use a loop to find it.
To multiply in a loop, start with 1.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, compare your working with the solution.
Plan. Multiply in every round. Start with result = 1, not 0, because multiplying by 0 would always give 0.
| Round | i | result after the round |
|---|---|---|
| 1 | 1 | 1 |
| 2 | 2 | 2 |
| 3 | 3 | 6 |
| 4 | 4 | 24 |
| 5 | 5 | 120 |
Answer: .
Log in to join the discussion.
Loading…