Sum of squares of 3 consecutive numbers is not a perfect square I'm trying to show that $(n-1)^2+n^2+(n+1)^2=a^2$ does not have a solution for $n,a\in \Bbb N$. I've written $(n-1)^2+n^2+(n+1)^2=3n^2+2$, so what I need to show is that $3n^2+2$ cannot be a perfect square. From here and here I understand that there is some relationship between perfect squares and modulo, but I fail to see which is it or how should apply it in my case. I do understand, however, that, in the case of 5 consecutive numbers, $n^2+2$ needs to be a multiple of 5.
 A: You are nearly there. Now just use the fact that $a^2 \ne 2 \pmod 3$.
The proof is here, which relies on the fact that you can just check $n=0,1,2$ (or even better, $n=-1,0,1$) for a result that holds for all natural $n$.
A: The formulas for the sum of consecutive squares up to $n$ is $\frac{n(n+1)(2n+1)}{6}$.
So, the sum of $k$ consecutive squares starting with $n$ is
$\displaystyle \frac{ (n+k-1)(n+k)(2n + 2k -1) }{6} - \frac{ (n-1)n(2n-1)}{6}$
(I had an off-by-one error so I solved for 4 through 7 instead of 3 through 6.)
For $k = 4$ we get $2(2n^2 + 6n + 7 $. For this expression to be a square, the right hand side must be of the form $2x^2$. But $2n^2 + 6n + 7$is always odd.
For $k = 5$ we get$5( n^2 + 4n + 6 )$. Can the right hand-side be divisible by 5?
Working modulo 5, the right-hand side gives $n^2 - n + 1$ which doesn’t have a root. (You can verify that by checking $n= 0$through $n=4$.) So the original quadratic term can’t be divisible by 5, and the sum of squares is not a square.
For $k = 6$ we get $6n^2 + 30n + 55$. There’s no obvious modulus to try here, but 4 is usually a convenient one, because squares mod 4 have values 0 or 1. The polynomial is always equal to 3 mod 4, so it can’t be a square.
For $k = 7$ we get $7(n^2 + 6n + 13)$. The same trick as $k = 5$ works here. Plug in the values $n = 0$ through $n = 6$ into the polynomial, computing mod 7. The polynomial never has value 0, so it can’t be divisible by 7.
I hope this answer your questions and feel free to reach out of you have any doubt.
thanks.
A: Toby Mak's hint settles the question but I would like to rephrase the answer without using congruences to make it comprehensible to those not-so-much into math, as this result comes up on the first page in Google search.
In order to show that
$$ (n - 1)^2 + n^2 + (n + 1)^2 \neq a^2 $$
$$ n, a \in \mathbb N $$
We will try to perform reductio ad absurdum by assuming that there is $a \in \mathbb N$ that satisfies the equation:
$$ (n - 1)^2 + n^2 + (n + 1)^2 = a^2 $$
We expand the left-hand side of the equation and thus get:
$$ 3n^2 + 2 = a^2 $$
Notice that the left-hand side of the equation divided by $3$ gives a remainder of $2$.
That implies a question - what is the remainder of the right-hand side when divided by $3$?
We've got three cases to consider
$$ a = 3k + 0 \lor a = 3k + 1 \lor a = 3k + 2, k \in \mathbb N $$
It's clear that if $a = 3k$ then the remainder of $a^2$ is $0$.
If $a = 3k + 1$ , then $a^2 = 3(3k^2 + 2k) + 1$ and thus the remainder is $1$.
If $a = 3k + 2$ , then $a^2 = 3(3k^2 + 4k + 1) + 1$, so the remainder is again $1$.
Hence, we arrived to a contradiction as it is imposible for a number which divided by 3 gives the remainder of $2$ to be equal to a number which divided by $3$ gives a remainder of $0$ or $1$.
Q.E.D.
