Problem

Source: Romania TST 2022

Tags: number theory, Sequence, romania, Romanian TST



Fix a nonnegative integer a0 to define a sequence of integers a0,a1, by letting ak,k1 be the smallest integer (strictly) greater than ak1 making ak1+ak into a perfect square. Let S be the set of positive integers not expressible as the difference of two terms of the sequence (ak)k0. Prove that S is finite and determine its size in terms of a0.