# How many ways can $2^{2012}$ be expressed as the sum of four (not necessarily distinct) positive squares?

How many ways can $$2^{2012}$$ be expressed as the sum of four (not necessarily distinct) positive squares? Thanks!

For those curious, the solution which I have trouble comprehending is item 2 from the PUMaC 2012 NT Contest.

The solution verbatim:

We have the equation $$a ^2$$ +$$b ^2$$ +$$c ^2$$ +$$d ^2$$ = $$2^{2012}$$. First, consider the problem modulo $$4$$. The only residues of squares modulo $$4$$ are $$0$$ and $$1$$. If all of the squares have residues of 1 modulo 4, then they are all odd and we consider the problem modulo $$8$$. The only residues of squares modulo $$8$$ are $$0, 1$$, and $$4$$, and because $$2^{2012} ≡ 0 \pmod 8$$, we see that the squares cannot all be odd, so they must all be even. If all of the squares are even, then we divide both sides by $$4$$ and repeat the process. We see that the only solution is $$a = b = c = d = 2^{1005}$$ , so there is only 1 solution.

Notice that the solution mentions that $$a,b,c$$, and $$d$$ all being $$1$$ modulo $$4$$ is not possible because $$2^{2012}$$ is $$0$$ modulo $$8$$. However, what if $$a^2,b^2,c^2,d^2$$ were $$5,1,1,$$ and $$1$$ modulo $$8$$ respectively? All $$4$$variables will be odd, can satisfy $$1$$ modulo $$4$$, as well as satisfy the condition of $$0$$ modulo $$8$$. So how is this reasoning valid? (I know I must have some logistical error since Princeton University is always right, but I don't know where my logic is wrong) Thanks, everyone.

Edit: I realized that my question was wrong and I think I understand now.

• This must be a contest question. Which contest was it from? – Parcly Taxel Apr 14 at 6:55
• Parcly Taxel, It's the PUMaC Contest 2012 Number Theory #2, but I don't quite understand their solution or reasoning. – Joshua Yang Apr 14 at 6:57
• I guess you might learn more if you present in another post what you don't understand about the solution presented by PUMaC (which is elementary and goes along the same lines I would have used to attack the problem), than now knowing the Jacobi four-square theorem which is nice of course but much more limited in application than general knowledge how squares behave mod 4 and mod 8. – Ingix Apr 14 at 10:06
• Hint: Working modulo 32, we must have $0 + 0 + 0 + 0 \equiv 0 \pmod{32}$. (Can you show why? It might be easier to work mod 16 first.) So we can divide by 4 and repeat (until we cannot take mod 32 any more). – Calvin Lin Apr 14 at 14:44

By Jacobi's four-square theorem, the number of solutions where the squares may be of zero or negative numbers and where order matters is $$24$$ times the sum of odd divisors of $$2^{2012}$$. But the only odd divisor of $$2^{2012}$$ is $$1$$, so there are $$24$$ solutions in the generalised sense. We can easily list them all out: they are all permutations and sign choices of $$(\pm2^{1006})^2+0^2+0^2+0^2$$ and $$(\pm2^{1005})^2+(\pm2^{1005})^2+(\pm2^{1005})^2+(\pm2^{1005})^2$$ So, when it comes to all positive squares, there is only one solution. $$2^{2012}=(2^{1005})^2+(2^{1005})^2+(2^{1005})^2+(2^{1005})^2$$