$a+n^2$ is the sum of two perfect squares $a+n^2$ is the sum of two perfect squares for a given positive integer $a$ and all positive integers $n$.
Show that $a$ is a perfect square.
At first I thought of putting a bound on the difference between perfect squares up to a point, like maybe choosing $n=c$ so that one of the squares on the right hand side is the smallest, to try and show that if $a = x^2 +  k< (x+1)^2$ that there would have to be two pairs of squares with the same difference, but I can't seem to work out the details

The general solution of the equation
$$x^2+y^2=z^2+w^2$$  is given by the identity with four arbitrary parameters
$$(tX+sY)^2+(tY-sX)^2=(tX-sY)^2+(tY+sX)^2$$
Let $n$ be any integer so we have $$a+n^2=z^2+w^2$$Making
$$n=tY-sX\\z=tX-sY\\w=tY+sX$$ we have three equations with four unknowns which in general have infinitely many solutions. Any way we have
$$n^2=t^2Y^2+s^2X^2-2stXY\\z^2=t^2X^2+s^2Y^2-2stXY\\w^2=t^2Y^2+s^2X^2+2stXY$$ which implies $$z^2+w^2-n^2=t^2X^2+s^2Y^2+2stXY=(tX+sY)^2$$ Since $$a=z^2+w^2-n^2$$ we have
$$a=(tX+sY)^2$$ We are done.
