Problem

Source: IMO 2017 Problem 1

Tags: number theory, IMO, IMO 2017, IMO Shortlist, Sequence



For each integer $a_0 > 1$, define the sequence $a_0, a_1, a_2, \ldots$ for $n \geq 0$ as $$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$ such that there exists a number $A$ such that $a_n = A$ for infinitely many values of $n$. Proposed by Stephan Wagner, South Africa