5. On the blackboard, the number 1 is written. A move consists of erasing the number on the board and replacing it with either double the number or the number that is one less. The number 1, for example, can be replaced by 2 (double) or 0 (one less), and if the number 5 is on the board, it can be replaced by 10 or 4.

What is the minimum number of moves needed to write the number 2021 on the board?
A) 14
B) 15
C) 16
D) 17
E) 18
A5. B) 15 We will reason from back to front. The number 2021 is odd, so the last number written before it must have been 2022. For the number before that, there are now two possibilities: 2023 or 1011. We will now show that in the solution with the minimum number of moves, this number must have been 1011. In other words: whenever we can divide by 2 in our reverse reasoning, it is always the best.

Suppose we first add 1 to 2022 a number of times before dividing by 2, say we add 1 $n$ times and then divide by 2. Then we are left with the number $\frac{2022+n}{2}$. Since this must be an integer, $n$ must be divisible by 2. The number $\frac{2022+n}{2}$ is also equal to $1011+\frac{n}{2}$. We could have also first divided by 2 and then added 1 $\frac{n}{2}$ times. Since $\frac{n}{2}$ is smaller than $n$, this takes fewer moves. Dividing by 2 first is thus always optimal.

The numbers we get from back to front are thus:

$$
2021,2022,1011,1012,506,253,254,127,128,64,32,16,8,4,2,1
$$

We see that at least 15 moves are needed to write down 2021.