4. A sequence of integers $a_{1}, a_{2}, a_{3}, \ldots$ is defined by
$$
\begin{array}{c}
a_{1}=k, \\
a_{n+1}=a_{n}+8 n \text { for all integers } n \geq 1 .
\end{array}
$$

Find all values of $k$ such that every term in the sequence is a square.
SolUtion
First solution
We have $a_{2}=a_{1}+8$ and the first two terms are squares, so we have $8=b^{2}-a^{2}=(b+a)(b-a)$ where $a$ and $b$ are positive integers.
Hence either $b-a=1$ and $b+a=8$, which is impossible for integers, or $b-a=2$ and $b+a=4$, so $a=1$ and $b=3$. Hence the only possible value of $k$ is 1 .
Alternatively, suppose that all the terms are squares, with the first two differing by 8 . Note that 16 and 25 differ by 9 and the gaps between successive squares beyond that are shown to be greater than 9 . It follows that the first two terms could only be $1,4,9$ or 16 . It is easy to observe that this forces $a_{1}=1$ and $a_{2}=9$, and so the only possible value of $k$ is 1 .
Evaluating, we obtain the sequence $1,9,25,49, \ldots$ which are all perfect squares, and we must show that this pattern continues.
From the definition of the sequence, we have $a_{n}=1+8(1+2+\cdots+(n-1))$, but we need a simpler expression for the sum $1+2+\cdots+(n-1)$. One method is to consider a rectangle of dots divided into two triangles.
The grey dots represent the numbers 1 to 7 , and the black dots represent the numbers 7 to 1 . Together they form a rectangle with $7 \times 8$ dots.
Hence $1+2+3+4+5+6+7=\frac{1}{2}(7 \times 8)$ and in general $1+2+\cdots+(n-1)=\frac{1}{2}(n-1) n$
As a consequence we have $a_{n}=1+4(n-1) n=(2 n-1)^{2}$, which is a perfect square.
Second solution
We have $a_{n}=k+(1+2+\cdots+(n-1))$ and so $a_{n}=k+4(n-1) n=4 n^{2}-4 n+k$, as above, but for general $k$. Rearrange this to obtain $a_{n}=(2 n-1)^{2}+k-1$
If $a_{n}$ is always square, then we have an infinite number of pairs of squares which differ by a fixed value $k-1$. However this cannot happen if $k-1>0$, since the gap between consecutive squares $N^{2}$ and $(N+1)^{2}$ is $2 N+1$, which will eventually be larger than $k-1$ for a fixed $k \geq 2$
Hence $k=1$ and $a_{n}=(2 n-1)^{2}$