Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
Add the numbers one after the other. Stop as soon as the total is more than . Which number was added last, and what is the total?
The loop stops as soon as the total is more than 50.
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. Keep a total and a counter i. In each round, add 1 to i, then add i to the total. Repeat while the total is not yet more than 50.
Totals after each number: 1, 3, 6, 10, 15, 21, 28, 36, 45, 55.
After adding 9 the total is 45, which is not more than 50. After adding 10 the total is 55.
Answer: the last number added is , and the total is .
Log in to join the discussion.
Loading…