## Task B-3.5.

Mate and Roko, while preparing for a competition, were challenging each other with "unsolvable" problems. So Roko asked Mate: Do you know what the sum of the digits of the number $3^{2018}$ is?

To this, Mate replied with a new question:

I don't know, but do you know what the 2018th number is if you continue the sequence where the first number is $3^{2018}$, the second number is the sum of its digits, the third number is the sum of the digits of the second number, and so on? Each subsequent number in this sequence is equal to the sum of the digits of the previous number!

Show that Mate's question is solvable and determine the 2018th number in this sequence.
## Solution.

Let's denote the first, second, third, ..., 2018th term of the given sequence of numbers as $a_{1}, a_{2}, a_{3}, \ldots, a_{2018}, \ldots$.

Notice that $a_{1}=3^{2018}=9 \cdot 3^{2016}$.

Since the first term of the sequence is divisible by 9, the sum of its digits is also divisible by 9. Therefore, the number $a_{2}$ is divisible by 9, and consequently, all subsequent terms of the sequence are also divisible by 9.

Since $a_{1}=3^{2018}=9^{1009}<10^{1009}$, the first term of the sequence cannot have more than 1009 digits, and each digit is at most 9. Therefore, $a_{2} \leqslant 9 \cdot 1009=9081$.

Thus, the second term of the sequence has at most 4 digits, so the third term of the sequence is at most $4 \cdot 9=36$.

Since the third term of the sequence is divisible by 9, it can only be $9, 18, 27$, or 36. In any case, the sum of its digits is 9, so each subsequent term of the sequence is equal to 9. Therefore, the 2018th term of the sequence is equal to 9.

## NATIONAL MATHEMATICS COMPETITION

## 4th grade - high school - B variant

Poreč, April 13, 2018.