# Question about the sum of four squares

Let's say I have four integers such that:

$a^2+b^2+c^2+d^2=23$

How many of them are even ?

a) $0$

b) $1$

c) $2$

d) $3$

e) $4$

I know that an even number plus or times an even number is even, an odd plus an odd is even too, an odd times an even is even while an odd times an odd is odd as an even plus an odd is.

Being $23$ odd to get and odd sum I need to have $1$ or $3$ even numbers so I think both b and d are right, however you can only choose one.

A friend of mine says that the only solution (not counting permutations) is: $a=b=3; c=2; d=1$ and so the answer is b. However how can I check that this is the only one ? I can do this by hand in this case however if instead of $23$ we have $128273917$ this would be pretty troublesome.

Since I'm not interested in the particular result but the general procedure, how can I find solutions to (and check how many others there are) to : $a^2+b^2+c^2+d^2=k$ ? Can I determine how many of $a; b; c; d$ are even/odd without actually compute such solutions ?

Note that the question doesn't specify if we are working with positive or negative integers or both, this is not big deal considering their squares however involving or not $0$ could change something I guess, in the same way one could not consider $0$ as even and $1$ as odd as they are "too trivial".

• Hint: for all integers $n$, we have $n^2\equiv 0$ or $1 \bmod 4$. – TonyK Sep 19 '16 at 16:29
• You have used sound logic to narrow it down to 1 or 3. Suppose the answer is 3. How many combinations of 3 even integers are there before their sum is greater than 24. The set is small, and you can brute force your way though quickly enough. – Doug M Sep 19 '16 at 16:43

## 1 Answer

An integer square is always $\equiv 0,1\pmod{4}$. Since $a^2+b^2+c^2+d^2=23\equiv 3\pmod{4}$, exactly one integer among $\{a,b,c,d\}$ is even. We may deduce the same from the fact that $23$ has a unique representation as a sum of four squares up to the ordering of terms: $$23 = 1^2+2^2+3^2+3^2.$$