1. On the board, there is a four-digit number divisible by eight, whose last digit is 8. If we replaced the last digit with the digit 7, we would get a number divisible by nine. However, if we replaced the last digit with the digit 9, we would get a number divisible by seven. Determine the number written on the board.
SOLUTION. Let $n$ be the three-digit number determined by the first triplet (from the left) of the sought four-digit number, which then equals $10 n+8$. According to the problem statement, we have

$$
\begin{array}{l|l}
8 & 10 n+8, \\
9 & 10 n+7, \\
7 \mid 10 n+9
\end{array}
$$

From relation (1), it follows that $8 \mid 10 n$ or $4 \mid 5 n$. Since the numbers 4 and 5 are coprime, $4 \mid n$ or $n=4 k$, where $k$ is a natural number. Substituting $n=4 k$ into relation (2) gives $9 \mid 40 k+7$ or $9 \mid 4 k+7$. From the table of remainders of the numbers $4 k+7$ when divided by nine

| $k$ | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| ---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| $4 k+7$ | 7 | 2 | 6 | 1 | 5 | 0 | 4 | 8 | 3 |

we see that this number is divisible by nine if and only if the number $k$ gives a remainder of 5 when divided by nine. Therefore, $k=9 l+5$, where $l$ is an integer, so $n=4 k=36 l+20$. Substituting such an $n$ into relation (3) gives $7 \mid 360 l+209$ or $7 \mid 3 l-1$. Again, we construct a table of remainders, this time for the number $3 l-1$ when divided by seven:

| $l$ | 0 | 1 | 2 | 3 | 4 | 5 | 6 |
| ---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| $3 l-1$ | 6 | 2 | 5 | 1 | 4 | 0 | 3 |

We see that $7 \mid 3 l-1$ if and only if $l=7 m+5$, where $m$ is an integer. From this, we get that all integer $n$ satisfying the triplet of conditions (1)-(3) are of the form $n=36 l+20=$ $=252 m+200$.

Let us add that instead of constructing tables, we could have used the transformations

$$
\begin{aligned}
40 k+7 & =36 k+4(k-5)+27 \\
360 l+209 & =357 l+3(l-5)+224
\end{aligned}
$$

from which we would again get $9 \mid k-5$ and $7 \mid l-5$.

The number $n=252 m+200$ is a three-digit number only for $m \in\{0,1,2,3\}$; the sought $n$ is therefore in the set $\{200,452,704,956\}$ and the number on the board was one of the numbers $2008,4528,7048$, 9568. By checking (which, however, is not necessary with our approach), we can verify that each of these four numbers satisfies the problem statement.