# Perfect square expression mod 4

I have following expression: $$2n(n+1)$$ Where n is a natural number. We want to know if there exists a subsequence of natural numbers that makes this expression a perfect square. According to existing theorem this expression should be 0 or 1 mod 4. Let's rewrite with $2l$ for $n$. We get: $$8l^2+4l=4(2l^2+l)$$ Which is 0 mod 4. But if we substitute $l=1$ our expression is $12$ which is not a perfect square. Where did I make a mistake?

• Your mistake is that you are assuming $n$ is even. A fact is that exactly one of the numbers $n$ and $n+1$ is even (so $4\mid n(n+1)$), not necessarily $n.$
– CIJ
Nov 25, 2016 at 20:59

If $n$ is a perfect square, $n \equiv 0 \mod 4 \vee n \equiv 1 \mod 4$ but $n \equiv 0 \mod 4 \vee n \equiv 1 \mod 4 \not\Rightarrow n$ is a perfect square.
For example $5 \equiv 1 \mod 4$ and 5 is not a perfect square.
So the cases are $n=x^2,n+1=2y^2$ or $x=2x^2, n+1=y^2$. This means you are solving $2y^2-x^2=\pm 1$. This does have infinitely many solutions and is a case of Pell's equation.