For every integer $a_{0}>1$, we define the sequence $a_{0}, a_{1}, a_{2}, \ldots$ as follows. For every $n \geq 0$,

$$
a_{n+1}= \begin{cases}\sqrt{a_{n}}, & \text { if } \sqrt{a_{n}} \text { is an integer, } \\ a_{n}+3 & \text { otherwise. }\end{cases}
$$

Determine all values of $a_{0}$ for which there exists a number $A$ such that $a_{n}=A$ holds for infinitely many $n$.
# Gáspár Attila's solution.

1. statement: If $a_{0} \equiv 0(\bmod 3)$, then the sequence contains the number 3.

We will prove this by complete induction on $a_{0}$. If $a_{0}=3$, then the statement is trivial. If $a_{0}=6$, then $a_{1}=9$, and $a_{2}=3$, so the statement is true. From now on, we can assume that $a_{0} \geq 9$.

It is clear that the first perfect square in the arithmetic sequence $a_{0}, a_{0}+3, a_{0}+6, \ldots$ is in the sequence. Every element of the sequence is divisible by 3, so this perfect square is of the form $x^{2}=(3 k)^{2}$. There are infinitely many perfect squares divisible by 3, so the sequence contains a perfect square. The $(3(k-1))^{2}=(x-3)^{2}$ does not appear in the sequence, so $a_{0}>(x-3)^{2}=$ $x^{2}-6 x+9=x(x-6)+9>x+9>x$. The $x^{2}$ is in the sequence, so $x$ is also in the sequence. $x(x-2)^{2}=x^{2}-4 x+4=$ $x(x-4)+4>x+4>x$. By the induction hypothesis, the statement is true.

3. statement: If $a_{0} \equiv 2(\bmod 3)$, then the sequence is strictly increasing.

A perfect square cannot be of the form $3 k+2$. Thus, the sequence $a_{0}, a_{0}+3, a_{0}+6, \ldots$ does not contain a perfect square. Then $a_{1}=a_{0}+3, a_{2}=a_{0}+6, \ldots, a_{n}=a_{0}+3 n$. This proves the statement.

It is clear that if $a_{0}$ is not divisible by 3, then by the 2nd and 3rd statements, the sequence is eventually strictly increasing. Thus, there is no $A$ that the sequence contains infinitely often.

Therefore, there is an $A$ that the sequence contains infinitely often if and only if $3 \mid a_{0}$.