This question on MSE asked the following:

"Given $x,y,z \in \mathbb{N},$ find probability that $x^2+y^2+z^2$ is divisible by $7.$"

The OP did not declare the assumed probability model, and was duly criticised for that. On the other hand, it is only natural to assume that $x$, $y$, $z$ are independently uniformly distributed mod $7$.

A case analysis then shows that that the probability in question is ${1\over7}$. This simple result led me to solve the same problem for the primes $p=3$, $5$, $11$, and $13$. In each case I obtained ${1\over p}$ as result. Further experiments showed that the remainder of $s=x^2+y^2+z^2$ mod $p$ is not uniformly distributed mod $p$, but that in any case the probability of $s=0$ mod $p$ is equal to ${1\over p}$ for all $p\leq107$. This leads to the following

Conjecture. Let the integeres $x$, $y$, $z$ be independently uniformly distributed modulo the prime $p$. Then the probability that $s:=x^2+y^2+z^2$ is divisible by $p$ is equal to ${1\over p}$.

Maybe this well known. Otherwise I'd like to see a proof.

  • $\begingroup$ If the conjecture is true this probably means that $w:=x^2+y^2+z^2$ is and uniformly distributed random variable in $\Bbb N$. $\endgroup$
    – Masacroso
    Commented Feb 27, 2017 at 20:38
  • $\begingroup$ so far, this is part of theorem 4.12 in Charles Small, Arithmetic of Finite Fields. Alright, it is exactly theorem 4.6 on page 91, need notation.... $\endgroup$
    – Will Jagy
    Commented Feb 27, 2017 at 20:47

1 Answer 1


Found it. Given odd dimension $n$ and quadratic form $$ f = a_1 x_1^2 + a_2 x_2^2 + \cdots + a_n x_n^2, $$ everything in a finite field with odd number of elements $q,$ the count $$ \#\left(f = b\right) \; = \; q^{n-1} + q^{(n-1)/2} \; \; \chi \left( \; (-1)^{(n-1)/2} \; b a_1 a_2 \ldots a_n\right). $$ At the bottom of page 91 Small points out that $$ \#\left(f = 0\right) \; = \; q^{n-1} . $$ When $b \neq 0$ we need to know what $\chi$ means.

Aah. Page 86, very simple. We have finite field $F$ and element $a.$ First $\chi(0) = 0.$ If $a$ is a nonzero square, $\chi(a)=1.$ If $a$ is nonzero and not a square, $\chi(a)=-1.$

Charles Small, Arithmetic of Finite Fields, Theorem 4.6 on page 91,


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .