8. Masha, bored during a math lesson, performed the following operation on a certain 2015-digit natural number: she discarded the last digit of its decimal representation and added twice the discarded digit to the number obtained by multiplying the remaining number by 3. She then performed the same operation on the resulting number, and so on. After applying this operation multiple times, the numbers Masha obtained stopped changing, and she stopped.

a) What number did Masha end up with?

b) What is the smallest number Masha could have started with (indicate its last two digits)
Answer: a) 17; b) 09 (the number $100 \ldots 0009$).

Solution. a) Let this number be $n$, ending in the digit $y$. Then $n=10 x+y$ after the next operation will become $3 x+2 y$. The equation $10 x+y=3 x+2 y$ is equivalent to $7 x=y$ and, since $y$ is a digit, then $y=7, x=1$. Therefore, $n=17$.

b) Note that if the initial number is not equal to 17, then it must decrease: $10 x+y>3 x+2 y \Leftrightarrow 7 x>y$ (which for $x \neq 0$ and $x \neq 1$ is always true). From the relation $2(10 x+y)=17 x+3 x+2 y$ it follows that the number $10 x+y$ is divisible by 17 if and only if $3 x+2 y$ is divisible by 17. Since the stabilization of the operation occurs at the number 17, the initial number must also be divisible by 17.

Let's find the smallest 2015-digit number that is divisible by 17. For convenience, let's list the remainders of the powers of 10 when divided by 17 (see table):

| Power | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- |
| Remainder | 10 | 15 | 14 | 4 | 6 | 9 | 5 | 16 | 7 | 2 | 3 | 13 | 11 | 8 | 12 | 1 | 10 |

Since the remainders repeat every 17 powers, and $10^{16} \equiv 1(\bmod 17)$ (this notation means that $10^{16}$ and 1 give the same remainder when divided by 17), and $2014=16 \cdot 125+14$, then $10^{2014} \equiv 10^{14} \equiv 8(\bmod 17)$, so $10^{2014}+9$ is divisible by 17. This will be the smallest 2015-digit number that is divisible by 17. It ends in 09.

Answer for variant 152: a) 17; b) 99 (the number 999...9999).

Answer for variant 153: a) 17; b) 05 (the number 100...0005).

Answer for variant 154: a) 17; b) 88 (the number 999...9988).