Problem

Source: Romania TST 2022

Tags: number theory, Sequence, romania, Romanian TST



Fix a nonnegative integer $a_0$ to define a sequence of integers $a_0,a_1,\ldots$ by letting $a_k,k\geq 1$ be the smallest integer (strictly) greater than $a_{k-1}$ making $a_{k-1}+a_k{}$ into a perfect square. Let $S{}$ be the set of positive integers not expressible as the difference of two terms of the sequence $(a_k)_{k\geq 0}.$ Prove that $S$ is finite and determine its size in terms of $a_0.$