# Number of nonnegative integer quintuples that $x^2+y^2+z^2+w^2+v^2=40$

How many quintuples ($5$-pairs) that are consisting of nonnegative integers that satisfy: $$x^2+y^2+z^2+w^2+v^2=40$$

$A)\space 56$

$B)\space 66$

$C)\space 112$

$D)\space 120$

$E)\space 122$

I don't know what to try. Should I count them? Or is there some theorem?

• Does order count? Sep 7, 2017 at 8:50
• @FrancescoPolizzi Typically, the terms "$n$-tuple" are used when the order counts.
– user228113
Sep 7, 2017 at 8:57
• @G.Sassatelli: well, I guess it depends on the context. In order to avoid any ambiguity, in problems like this I think it is better to write "ordered n-tuples" or "unordered n-tuples". Sep 7, 2017 at 9:06
• Order doesn't count AFAIK Sep 7, 2017 at 9:09
• Is the last choice =222 ? Sep 7, 2017 at 9:14

Though mixedmath answer is the right way to do it a sneaky way could be to notice that $x=y=z=v=w$ has no solution. And for any other choice the number of reorderings of one solution is divisible by $5$ i.e $(1,1,1,1,6),(1,1,1,6,1),(1,1,6,1,1),(1,6,1,1,1),(6,1,1,1,1)$ there are $5$ reorderings of $(1,1,1,1,6)$ and $5$ is divisible by $5$. This implies that the sum of all combinations must be divisible by $5$ so D must be the solution, since it's the only number divisible by $5$.

• Nice....... On multiple-choice tests is is often effective to look for a way to eliminate some choices. (And if you can eliminate even one choice, but can do no more, it is statistically in your favor to guess. That is an example of how to use applied math to improve your pure-math test scores.) Sep 7, 2017 at 10:01

The largest integer is clearly at most $6$.

Suppose the largest is exactly $6$. Then the other four squares must add to $4$, which can occur if they are all $1$ or if one is $2$ and the others are all $0$. So the two solution shapes in this case are $(1,1,1,1,6)$ and $(0,0,0,2,6)$.

Suppose the largest is exactly $5$. Then the other four squares must add to $15$. At least one of these squares must be $9$ (by quick check), so the three remaining squares must add to $6$. This can only be done as $1 + 1 + 4$. In this case, there is one solution shape, namely $(1,1,2,3,5)$.

Suppose the largest is exactly $4$. Then the remaining four squares must add to $24$. If another square is $4$, then three squares must add to $8$, which can only be done as $0+4+4$. Alternately, if the second largest square is $3$, then the three remaining squares must add to $15$, but this cannot occur (as noted above). Thus in this case, there is only the solution shape $(0,2,2,4,4)$.

If the largest is exactly $3$, then it's apparent that the only available solution shape is $(2,3,3,3,3)$ (by quick check, similar to above).

As the largest integer must be greater than $3$, this classifies all solution shapes.

What remains is to count how many of each solution shape there actually are. For instance, in $(1,1,1,1,6)$, it's apparent that any of the five integers can be chosen as $6$, and so on. It's quick to do this for each solution shape, but I leave the counting to you.

$$clear;\\ sum=0;\\ for \space x=0:6\\for \space y=0:6 \\ for \space z=0:6 \\ for \space t=0:6 \\ for \space w=0:6 \\ if \space x^2+y^2+z^2+t^2+w^2==40 \\ sum=sum+1 \\ else \\ sum=sum+0 \\ end \\ end \\ end \\ end \\ end \\ end$$ This is a Matlab program that counts what you need . answer is 120 ( I think)