Problem

Source: Peruvian IMO TST 2019, P4

Tags: Sequences, floor function, number theory



Let $k\geq 0$ an integer. The sequence $a_0,\ a_1,\ a_2, \ a_3, \ldots$ is defined as follows: $a_0=k$ For $n\geq 1$, we have that $a_n$ is the smallest integer greater than $a_{n-1}$ so that $a_n+a_{n-1}$ is a perfect square. Prove that there are exactly $\left \lfloor{\sqrt{2k}} \right \rfloor$ positive integers that cannot be written as the difference of two elements of such a sequence. Note. If $x$ is a real number, $\left \lfloor{x} \right \rfloor$ denotes the greatest integer smaller or equal than $x$.