# Integer $2n^2+2$ as the sum of 2,3,4, and 5 squares

If $n-1$ and $n+1$ are both primes, establish that the integer $2n^2+2$ can be represented as the sum of 2, 3, 4, and 5 squares.

I managed to solve 2 and 4 squares, since: $$2n^2+2 = (n+1)^2+(1-n)^2= n^2+n^2+1^2+1^2.$$

For 3 squares I thought the following. I do know that a positive integer can be represented as the sum of 3 squares if it is not of the form $4^n(8m+7)$. Since $n$ is even, $2n^2+2$ can be written as $8k^2+2$, which is not of the form $4^n(8m+7)$, so it can be represented as a sum of three squares.

Now I only need to prove the 5 squares part, but I don't know where to start. Any hints? Thank you in advance.

• Typically we allow 0^2 in the representation. If you were able to do this with 2 squares, then add 0^2 + 0^2 + 0^2 at the end. – Sungjin Kim Aug 5 '15 at 16:57
• Formally, the problem should be posed. $$x^2+y^2+z^2+r^2=2n^2+2$$ Or in a similar form. This means we need to solve the Diophantine equation of some sort. – individ Aug 5 '15 at 16:57
• If $n-1$ and $n+1$ are both prime then $n=4$ or $n$ is divisible by $6$ – Mark Bennet Aug 5 '15 at 17:16
• An extension of Lagrange's for square theorem states that any positive integer above 17 can be expressed as a sum of 5 positive squares. – Shailesh Aug 5 '15 at 17:21
• @user95864, any prime of the form $4k+1$ is representable as a sum of two squares. Suppose $n+1$ is of this form. Then $2n^2+2=(n+1)^2+(n-1)^2=(x^2+y^2)^2+(n-1)^2=(x^2-y^2)^2+(2xy)^2+(n-1)^2$. The other case is absolutely similar. Btw, Mark Bennet's comment is extremely useful in resolving the five squares part. – rah4927 Aug 5 '15 at 17:31