\section*{Problem \(6-331016=330916\)}

It is known that \(2^{10}=1024\).

Formulate a computer program that can determine the smallest natural exponent \(p>10\) for which the number \(2^p\) also ends in the digits ...024! Explain why the program you have formulated solves this problem!

Hint: It should be noted that for the numbers involved in the calculation, limitations on the number of digits may occur with common computer usage.
}

A BASIC program of the required type is, for example:

```

10 P = 10
20 Z = 24
30 P = P+1
40 Z = Z*2
50 IF Z > 999 THEN Z = Z-1000
60 IF Z <> 24 THEN GOTO 30
70 PRINT P

```

For values of the exponent \(p\), the last three digits of the power \(2^{p}\) are formed as an integer \(z\) with \(0 \leq z \leq 999\). Starting from the initial values \(p=10, z=024\) (lines 10, 20), the next values are found step by step:

In each step, \(p\) is incremented by 1 (line 30) and \(z\) is doubled (line 40). If a non-three-digit value results initially, only its last three digits are retained. This can be achieved by subtracting 1000 (line 50); because if \(0 \leq z < 1000\) held for the previous value of \(z\), the initially resulting value \(2 \cdot z < 2000\), and if \(1000 \leq 2 \cdot z\), the value obtained by subtracting 1000 again satisfies \(0 \leq 2 \cdot z - 1000 < 1000\).

By this step-by-step reduction, the large numbers \(2^{p}\) are avoided, as required by the "hint".

These steps are repeated until the sequence \(z=024\) is not reached again (line 60). Otherwise, the process ends with the output of the desired exponent \(p\) (line 70).

The end must be reached (no "infinite loop" occurs). This can be established as a result of a "risky test run" (and thus find the desired exponent \(p=110\)); it can also be proven that for every \(p \geq 3\), the sequence of the last three digits of \(2^{p}\) must repeat for a larger \(p\).

Solutions of the 1st Round 1993 adopted from [5]

\subsection*{7.35.2 2nd Round 1993, Class 10}