Show that $23a^2$ is not the sum of 3 squares. I know that Legendre's theorem states that a number is expressible as a sum of 3 squares iff. it's not of the form $4^x (8m+7)$, so I need to show that $23a^2$ is of this form, how could I go about doing this? 
 A: Note that $4^x(8m + 7)$ is a product of two terms:


*

*a power of $4$, and  

*the remaining odd part.


This motivates assuming $a$ to be of the form $2^xr$ where $r \ge 1$ is odd and $x \ge 0$. (Both $r$ and $x$ are integers.)
Note that every integer can indeed be written in the above form (in a unique manner).
Now, we get that $a^2 = 4^xr$. This is promising because we have gotten a $4^x$ term.
This shows that 
$$23a^2 = 4^x(23r^2).$$
Now, we need to show that $23r^2$ is of the form $8m + 7$. Note that $23 = 8\cdot2 + 7$.
So, if we can show that $r^2$ is of the form $8k + 1$, then we would be done.
This can be done easily by exhaustion.
Since $r$ is odd, there are only the following possibilities for $r$:
$r$ is of one of the following forms:


*

*$8k + 1$  

*$8k + 3$  

*$8k + 5$  

*$8k + 7$
You can square each and verify that $r^2$ is always of the form $8k + 1$. Thus, $23a^2$ further simplifies as
$$\begin{align}23a^2 &= 4^x(23r^2)\\
&=4^x(23(8k+1))\\
&=4^x(23\cdot8k + 16 + 7)\\
&=4^x((23k + 2)\cdot8 + 7)\\
&= 4^x(8m + 7),\end{align}$$
as desired.
A: If a number $n$ is of this form, then:
$$n = 4^x \left(8m + 7\right) = 4^x \cdot 8m + 7 \cdot 4^x = 23a^2$$
Therefore
$$n \equiv 7 \cdot 4^x \equiv \begin{cases}0 & \text{if } x > 1 \\4 & \text{if } x = 1\\7 & \text{if } x = 0\end{cases}\pmod{8}$$
and
$$n \equiv 23 a^2 \equiv \begin{cases}0 & \text{if } a \equiv 0 \pmod{4}\\4 & \text{if } a \equiv 2 \pmod{4}\\7 & \text{if } a \text{ is odd}\end{cases}\pmod{8}$$
Lets bust the case where $n \equiv 7 \pmod{8}$. It means that $a$ is odd. So $23a^2$ is odd, too. However $4^x \left(8m + 7\right)$ is even. Because $n$ can't be even and odd at the same time, it is a contradiction.
Next case: $n \equiv 4 \pmod{8}$
$$4 \left(8m + 7\right) = 23a^2 \quad a \in \{2,6,10,12,...\}$$
Because $\left(8m + 7\right)$ is not divisible by $4$, $a$ needs to be $2$, then:
$$8m + 7 = 23$$
Therefore $m = 2$.
So actually it is of the form!
$$4^1 \left( 8 \cdot 2 + 7 \right) = 23 \cdot 2^2$$
One possible solution: $x = 1$, $m = 2$, $a = 2$
