Problem

Source: Cono Sur Olympiad 2017, problem 6

Tags: cono sur, number theory



The infinite sequence $a_1,a_2,a_3,\ldots$ of positive integers is defined as follows: $a_1=1$, and for each $n \ge 2$, $a_n$ is the smallest positive integer, distinct from $a_1,a_2, \ldots , a_{n-1}$ such that: $$\sqrt{a_n+\sqrt{a_{n-1}+\ldots+\sqrt{a_2+\sqrt{a_1}}}}$$is an integer. Prove that all positive integers appear on the sequence $a_1,a_2,a_3,\ldots$