Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
Start with and keep doubling the number until it is more than . What is the final number, and how many doublings did it take?
Repeat while the value is not yet more than 100.
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. We do not know the number of rounds, so we use a while loop. Repeat while value <= 100, double it and count.
| Doubling | Value |
|---|---|
| start | 1 |
| 1 | 2 |
| 2 | 4 |
| 3 | 8 |
| 4 | 16 |
| 5 | 32 |
| 6 | 64 |
| 7 | 128 |
Answer: the final value is , after doublings. (Check: .)
Log in to join the discussion.
Loading…