<s>[INST] If $n$ is a positive integer greater than 1 such that $3n+1$ is perfect square, then show that $n+1$ is the sum of three perfect squares. If $n$ is a positive integer greater than 1 such that $3n+1$ is perfect square, then show that $n+1$ is the sum of three perfect squares.
My work:
$3n+1=x^2$
$3n+3=x^2+2$
$3(n+1)=x^2+2$
$(n+1)=\dfrac{x^2+2}{3}$
I have no clue what to do next. Please help!
 [/INST] This will give the answer : http://www.proofwiki.org/wiki/Integer_as_Sum_of_Three_Squares
You need to prove that $n+1=\frac{x^2+2}{3}$ is not of the form $4^k(8m+7)$ for $k,m\in \mathbb{N}$ and its not that difficult to show this.
For Square modulo 8 we know that $x^2 =0,1,4 \mod{8}$, so $x^2 +2 =2,3,6 \mod{8}$.
Since $x^2 +2 =0 \mod{3}$ we obtain that $\frac{x^2 +2}{3} = 1,2,A \mod{8}$ where $A=\frac{2+8a}{3}$, $a$ positive integer. And $A=\psi \mod{8}$ namely, $2=3\psi \mod{8}$ with $\psi\in\{0,1,...,7\}$. The only possible value is $\psi=6$ hence $\frac{x^2 +2}{3} = 1,2,6 \mod{8}$.
If it was of that particular form then:
For $m=0$,$k=0$ it is equal to 7 modulo 8
For $m=0$,$k=1$ it is equal to 4 modulo 8
For $m=0$,$k=2$ it is equal to 0 modulo 8
For $m>0,k>2$ it is equal to 0 modulo 8
So you obtain a contradiction.
</s>