why is the chance that $a^2+b^2+c^2$ is divisibile by $7$ when $a, b, c$ are positive integers equal to $1/7$?

Modulo $7$, any square is congruent to $0,1,2,$ or $4$. If one forms all possible sums of three residues and throws out repetitions (i.e., $001$ and $044$ both are congruent to $1$ modulo $7$) I obtain $20$ distinct sums: $3$ are congruent to $1, 3$ are congruent to $2, ..., 3$ are congruent to $6$, and TWO ($000$ and $124$) are congruent to $7$ or $0$ modulo $7$. Thus I obtain TWO favorable cases out of the twenty possible cases and the probability is $\frac{2}{20}=\frac{1}{10}$ which is not $\frac{1}{7}$. Where am I wrong?


Solution 1:

There are $7^3$ combinations of residue modulo $7$ for $a$, $b$, $c$. (That is, three independent selections from the set $\{0,1,2,3,4,5,6\}$.)

Of those, $49$ satisfy $a^2 + b^2 + c^2$ congruent to $0$ modulo $7$. They are $$ (a,b,c) \in \{ (0,0,0), (1,2,3), (1,2,4), (1,3,2), \\ \dots, (6,4,2), (6,4,5), (6,5,4)\} $$

At the very least, in your argument, there is only one residue that squares to $0$ and two residues squaring to each of $1$, $2$, and $4$, so treating these four squares as equally likely is an error. That is, there is only one set of residues whose squares are your $(0,0,0)$, but there are eight whose squares are your $(1,2,4)$. It's also not entirely clear in your writing that you have accounted for permutations. There is only one permutation of $(0,0,0)$, but there are six of $(1,2,4)$. So the $49$ ways to get $a^2 + b^2 + c^2$ congruent to zero have one way giving the squares $(0,0,0)$ and $6 \cdot 8$ ways to get the squares $(1,2,4)$.

Solution 2:

\begin{array}{|l|l|l|l|l|l|l|l|} \hline n & 1 & 2 & 3 & 4 & 5 & 6 & 7 \\ \hline n^{2} \bmod 7 & 1 & 4 & 2 & 2 & 4 & 1 & 0 \\ \hline \end{array}

By the table, we can observe that $(a,b,c)$ are either the permutations of $(1,2,4) $or $(0,0,0) $ and hence

$$ \begin{array}{l} \quad \displaystyle P\left(a^{2}+b^{2}+c^{2} \equiv 0(\bmod 7)\right) \\\displaystyle =\frac{6}{7} \times \frac{4}{7} \times \frac{2}{7}+\frac{1}{7} \times \frac{1}{7} \times \frac{1}{7} \\ =\displaystyle \frac{1}{7} \end{array} $$