Evochkimov

Find the smallest natural number $\$ \mathrm{~N}>9 \$$ that is not divisible by 7, but if any of its digits is replaced by 7, the resulting number is divisible by 7.
Let the smallest suitable number be of the form $\overline{a_1a_2\ldots a_n}$. From the condition, it follows that among its digits there are no 0 and 7. If the number contains digits 8 or 9, then they can be replaced by 1 or 2, respectively, to obtain a smaller number with the same property. Thus, the desired number consists of digits from 1 to 6.

Consider adjacent digits $a_k$ and $a_{k+1}$. By the condition, the numbers with the replaced digits $\overline{a_1a_2\ldots7a_{k+1}\ldots a_n}$ and $\overline{a_1a_2\ldots a_k7\ldots a_n}$ are divisible by 7, hence their difference is also divisible by 7, i.e., $10a_k \equiv a_{k+1} \pmod{7}$ for any $k$. Therefore, the number can only be structured as follows: 1 is followed by 3, 3 is followed by 2 (since the digit 9 is not in the number), and so on (see the figure).

![](https://cdn.mathpix.com/cropped/2024_05_06_1aa9346639cd54e59f2ag-19.jpg?height=229&width=243&top_left_y=1712&top_left_x=1776)

By the condition, the original number, with 7 instead of the last digit, is divisible by 7. Therefore, the original number without the last digit $\overline{a_1a_2a_3\ldots a_{n-1}}$ is divisible by 7. Using the congruence $10a_k \equiv a_{k+1} \pmod{7}$ several times, we get:
\[
\overline{a_1a_2\ldots a_{n-1}} = a_1 10^{n-2} + a_2 10^{n-3} + a_3 10^{n-4} + \ldots + a_{n-1} \equiv
\]
\[
\equiv 10a_1 \cdot 10^{n-3} + a_2 10^{n-3} + a_3 10^{n-4} + \ldots + a_{n-1} \equiv
\]
\[
\equiv 2 a_2 10^{n-3} + a_3 10^{n-4} + \ldots + a_{n-1} \equiv \ldots \equiv (n-1)a_{n-1} \pmod{7}.
\]
Since $a_{n-1}$ is not divisible by 7, we conclude that $n-1$ is divisible by 7, so the smallest possible $n$ is 8. Thus, the smallest possible number consists of at least eight digits. It remains to note that the number 13264513 satisfies the condition of the problem, and since it starts with 1, this number is the smallest.

## Answer

13264513.

Submit a comment