# Legendre's three-square theorem

Problem:

If $$n \in \mathbb{N}$$ can be represented as $$n = n_1^2 + n_2^2 + n_3^2 ,\quad n_1, n_2, n_3 \in \mathbb{Z},$$ show that then $$n \neq 4^a(8m+7)$$ for $$a,m \in \mathbb{Z}.$$

My solution:

Since this is the beginning of a math course in Discrete Mathematics, I don't think we're supposed to use the quadratic reciprocity law, Dirichlet's theorem on arithmetic progressions nor the equivalence class of the trivial ternary quadratic form. as listed on Wikipedia.

It also states on Wikipedia (Why?) that every square is congruent to either $$0,1,4$$ in $$\mathbb{Z}_8$$. So the sum of three squares $$n \in \{0,1,2,3,4,5, 6\} \subset \mathbb{Z}_8.$$ My initial plan was to show that $$4^a(8m+7) \in \{6,7\}$$. This not true though, as $$4^a \equiv 4$$ or $$\equiv 0$$ for $$a \geq 1$$. Thus $$4^a(8m+7) \equiv 0$$ or $$4$$.

Any hints?

Muchos gracias!

• On the question about $\mathbb{Z}^8$: $$0^2 = 0$$ $$1^2 = 1$$ $$2^2 = 4$$ $$3^2 = 9 = 1$$ $$4^2 = 16 = 0$$ $$5^2 = 25 = 1$$ $$6^2 = 36 = 4$$ $$7^2 = 49 = 1$$ And there are no more elements!
– fcz
Jan 27, 2021 at 17:02
• First, $4+1+1=6$, so you can reach the residue class $6\pmod 8$. More importantly, yes, this is a result where (as it turns out) one has to deal with the powers of $4$ separately first, before finishing it off with the $7\pmod 8$ observation. Try showing that if a multiple of $4$ can be written as the sum of three squares, then each of those squares must be even, and thus you can divide everything by $4$ and consider the new smaller number. Jan 27, 2021 at 17:03
• Sum of three squares is a multiple of 4 in $\mathbb{Z}_8$ or $\mathbb{Z}$? Jan 27, 2021 at 17:17
• So $4^a \equiv 0, 4$ mod 8. Thus $4^a(8m+7) \equiv 0,4$, but $(8m+7) \equiv 7, \forall m$. So $n \equiv 0,4$, so we have the possibiltes $\{n_1,n_2,n_3 \} \equiv (0,0,0), (0,0,4), (0,4,4)$. Is this what you meant and how do you come forward? Jan 28, 2021 at 10:12

Well as the equation $$n=n^2_1+n^2_2+n^2_3$$ has no integral solutions if $$n$$ is of the form $$n=8m+7$$ for some integer $$m$$--established in the comments, we can prove that the equation $$n=n^2_1+n^2_2+n^2_3$$ has no integral solutions if $$n$$ is of the form $$n=4^a(8m+7)$$ for some integers $$m, a \ge 1$$, by induction on $$a$$.
[To elaborate, as shown, there are no solutions to $$n=n^2_1+n^2_2+n^2_3$$ for $$n$$ of the form $$n=8m+7$$ i.e., $$a=0$$. So fix an $$a >0$$. We show that if there is a solution to $$n=n^2_1+n^2_2+n^2_3$$ for any $$n$$ of the form $$n=4^a(8m+7)$$, then there must be a solution to $$\tilde{n}=\tilde{n}^2_1+\tilde{n}^2_2+\tilde{n}^2_3$$ for some $$\tilde{n}$$ of the form $$\tilde{n}=4^{a-1}(8m+7)$$. As it has already been established in the comments that there is no solution to $$\tilde{n}=\tilde{n}^2_1+\tilde{n}^2_2+\tilde{n}^2_3$$ for some $$\tilde{n}$$ of the form $$\tilde{n}=(8m+7) =4^0(8m+7)$$ this establishes the desired result.]
The crux of the proof is this: Suppose $$n = 4^a(8m+7)$$ for $$a \ge 1$$. Then $$n \mod 4 = 0$$ and as every even square is $$0 \mod 4$$ and every odd square is $$1 \mod 4$$ [check this for yourself] it follows that $$n_1,n_2,n_3$$ must all be even. So then this implies $$\frac{n}{4} = \left(\frac{n_1}{2}\right)^2 +\left(\frac{n_2}{2}\right)^2 +\left(\frac{n_3}{2}\right)^2$$ must hold, with the $$\left(\frac{n_i}{2}\right)$$s; $$i=1,2,3$$ all integers and with $$\frac{n}{4} = 4^{a-1}(8m+7)$$.
• How do you move on with the $\frac{n}{4} = 4^{a-1}(8m +7)$? Jan 28, 2021 at 10:25
• Should you apply mod 8 on the equation $\frac{n}{4} = 4^{a-1}(8m + 7)$? Jan 28, 2021 at 13:49