TITLE: Sum of squares of 3 consecutive numbers is not a perfect square
QUESTION [1 upvotes]: 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.

REPLY [1 votes]: 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.
{"set_name": "stack_exchange", "score": 1, "question_id": 3365243}