TITLE: Multiples of 4 as sum or difference of 2 squares
QUESTION [7 upvotes]: Is it true that for any $n \in \mathbb{N}$ we can have $4n = x^{2} + y^{2}$ or $4n = x^{2} - y^{2}$, for $x,y \in \mathbb{N} \cup (0)$?
I was just working out a proof and this turns out to be true from $n=1$ to $n=20$. After that I didn't try, but I would like to see if a counterexample exists for a greater value of $n$.

REPLY [7 votes]: It is true because
$$ (n+1)^2 - (n-1)^2 = 4n $$

REPLY [4 votes]: Here is a hint: the form $x^2-y^2$ factors as $(x+y)(x-y)$.  Therefore, if you want to represent an integer $N$ as $x^2-y^2$, you can attempt to do so by choosing a factorization $N = ab$ and solving the linear system
$x+y = a$
$x-y = b$.
This system has the unique rational solution $x = \frac{a+b}{2}$, $y = \frac{a-b}{2}$.  This gives an integral solution iff $a$ and $b$ have the same parity.  Use this to show:
A positive integer $N$ is of the form $x^2 - y^2$ for $x,y \in \mathbb{Z}$ (possibly $0$) iff $N$ is odd or $N$ is divisible by $4$.
In particular, $4n$ is always of the form $x^2-y^2$.  You want a little more: that $x$ and $y$ are both nonzero.  Clearly $x$ cannot be zero, so you need to analyze the case $y = 0$ and show that whenever all possible solutions to $n = x^2 - y^2$ have $y = 0$, then there are nonzero $X$ and $Y$ such that $4n = X^2 + Y^2$.  This is not so hard...