# Deciding if numbers can be written as the sum of three squares

I am asked to decide if 154, 155 and 156 can be written as the sum of three squares. I am using the theorem that if $n\in S_3$ then $n\not= 4^e(8k+7)$. Now just looking at all of these numbers it doesn't seem to me that there is a way for any of them to be written this way so I think they must all $\in S_3$? Is this correct? Is there a specific way to show this or would have have to write out all possibilities such as $4^0(8(19)+2)...4^1...4^2$ for each?

If you know the deep theorem (whose proof is very far from being trivial, relying on Lagrange's identity for quaternions)

Every number that is not of the form $4^m(8k+7)$ is the sum of three integer squares

to check if $154,155,156$ are $\square+\square+\square$ is straightforward.

1. $154=2\cdot 77$, hence $\nu_2(154)$ is odd and there are no issues;
2. $155$ is odd and $\equiv 3\pmod{8}$, no issues;
3. $156=4\cdot 39$ and $39\equiv 7\pmod{8}$, hence $156\neq \square+\square+\square$.

For the first two numbers, you certainly can't apply that result and as a matter of fact, you could easily check that 154=144+9+1 and 155=121+25+9. For the third one, you might want to think about the fact that $156=4 \cdot 39 = 4 \cdot (8\cdot4 + 7)$.

We have $$3^2+8^2+9^2 = 154,$$ and $$5^2+7^2+9^2 = 155.$$ $156$ is not a sum of three squares, since $156 = 4\cdot(8\cdot4+7)$.