Problem

Source: Dutch IMO TST 2018 day 1 p3

Tags: number theory, Sum, floor function, Perfect Square



Let $n \ge 0$ be an integer. A sequence $a_0,a_1,a_2,...$ of integers is defined as follows: we have $a_0 = n$ and for $k \ge 1, a_k$ is the smallest integer greater than $a_{k-1}$ for which $a_k +a_{k-1}$ is the square of an integer. Prove that there are exactly $\lfloor \sqrt{2n}\rfloor$ positive integers that cannot be written in the form $a_k - a_{\ell}$ with $k > \ell\ge 0$.