Suppose that the sequence $\{a_n\}$ of positive integers satisfies the following conditions: For an integer $i \geq 2022$, define $a_i$ as the smallest positive integer $x$ such that $x+\sum_{k=i-2021}^{i-1}a_k$ is a perfect square. There exists infinitely many positive integers $n$ such that $a_n=4\times 2022-3$. Prove that there exists a positive integer $N$ such that $\sum_{k=n}^{n+2021}a_k$ is constant for every integer $n \geq N$. And determine the value of $\sum_{k=N}^{N+2021}a_k$.
Problem
Source: KMO 2022 P3
Tags: number theory, Perfect Squares, Sequence, Integer sequence
30.10.2022 07:00
Step 1. $a_n \geq a_{n+2022}$ pf) Let $S=\sum_{i=n+1}^{n+2021}a_i$. By the first condition, $a_{n+2022}$ is the minimal positive integer such that $S+a_{n+2022}$ is a perfect square. Since $\sum_{i=n}^{n+2021}a_i$ is also a perfect square, $a_n+S$ is a perfect square. $\therefore a_n \geq a_{n+2022}$ Step 2. We can find an integer $N$ such that $\sum_{i=n}^{n+2022}a_i$ is constant for all $n \geq N$. For an arbitrary integer $0\leq r < 2022$, sequence $(a_{2022q+r})$ is a monotone decreasing sequence. Since all terms are positive integer, there exists an integer $q_r$ such that $a_{2022q+r}$ is constant(denote as $c_r$) for all $q\geq q_r$. Hence, we can pick an integer $N$ such that $a_n = a_{n+2022}$ for all $n\geq N$. We can easily show that $\sum_{i=n}^{n+2021}a_i$ is constant for all $n \geq N$. Step 3. The constant value is $4043^2$. pf) Denote the constant value be $z^2$, and $M=2022N$. For an arbitrary integer $0\leq r<2022$, $a_{M+r}=c_r$. By the first condition, $a_{M+r}$ is the smallest positive integers $x$ such that $x+\sum_{i=M+r-2021}^{M+r-1}a_i$ is a perfect square. If $c_r > 2z-1$, since $\sum_{i=M+r-2021}^{M+r-1}a_i=z^2-c_r<z^2-2z+1=(z-1)^2$, $x=(z-1)^2-(z^2-c_r)$ can also be solution, which is smaller that $a_{M+r}$, contradiction. Thus, all $c_r\leq 2z-1$. By the second condition, $4\times 2022-3$ should be one of the $c_r$s, so $4\times 2022-3 \leq 2z-1$, $z \geq 4043$. Since $\sum_{r=0}^{2021}c_r = z^2$, $z^2 \leq 2022(2z-1)$. If $z \geq 4044$, $-2022\geq z^2-4044z=z(z-4044)\geq 0$, contradiction. $\therefore z=4043$, the constant value is $4043^2$.