Two five-digit numbers were written on the wall. Pat added a one in front of one of these numbers, and Mat added a one after the other. This resulted in two six-digit numbers, one of which was three times larger than the other.

Which five-digit numbers were originally written on the wall?

(L. Hozová)

Hint. Which of the newly created numbers was larger?
Both new numbers had the same number of digits, and the larger one was three times larger than the other. The larger number, therefore, could not start with a one - it was Mat's number.

Let the original five-digit number be denoted by $x$. Pat's modification gives the number $100000 + x$, and Mat's modification gives the number $10x + 1$. We have

\[
\begin{aligned}
10x + 1 & = 3(100000 + x), \\
7x & = 299999, \\
x & = 42857.
\end{aligned}
\]

The original number on the wall was written twice as the number 42857.

Notes. If we assume that Pat's new number was larger than Mat's, we would get

\[
\begin{aligned}
100000 + x & = 3(10x + 1), \\
99997 & = 29x.
\end{aligned}
\]

However, this does not lead to an integer solution (the remainder of 99997 divided by 29 is 5).

The problem can be solved as an algebrogram. Both options correspond to the following setups:

![](https://cdn.mathpix.com/cropped/2024_04_17_94af7d7a3fc4841f393fg-04.jpg?height=168&width=642&top_left_y=1778&top_left_x=707)

In the first case, we sequentially indirectly fill in $e=7, d=5, c=8, b=2, a=4$, which corresponds to the solution mentioned above. In the second case, we sequentially directly fill in $e=3, d=9, c=7, b=3, a=1$, which leads to a contradiction: the first digit in the result is 4, not the prescribed 1.