Cardinality of hypersphere over $\mathbb{F}_p$ is always divisible by $p$? I recently read an interesting post here (the second answer to this) about proving quadratic reciprocity by considering the set
$$S_p^{n-1} = \{(x_1,\dots,x_n)\in\mathbb{F}_p^n : x_1^2+\dots +x_n^2 = 1\}$$
Which is just the equation for an $(n-1)-$sphere with entries from a finite field.
Then, consider
$$N_p(n):= |S_p^{n-1}|$$
which just gives how many possible solutions to $x_1^2+\dots +x_n^2 = 1$ there are in $\mathbb{F}_p$.
It turns out that
$$N_p(2) \equiv 1 \mod p \iff p \equiv 3 \mod 4$$
and
$$N_p(2) \equiv -1 \mod p \iff p \equiv 1 \mod 4$$
for all $p$, which is interesting.
After reading the proof in the link above, I see why this is the case.
What I do not understand is that for $n>2$, I wrote some code and it seems
$$N_p(n) \equiv 0 \mod p$$
for all $p$.
So my question is

Why is it the case that $p$ divides $N_p(n)$ for all $n>2$? What does having a certain amount of solutions on a hypersphere over $\mathbb{F}_p$ have to do with being divisible by $p$?


I will illustrate this for $n = 3$ for simplicity, but the proof directly generalizes. Let's assume $p > 2$ as well (I didn't check $p = 2$)
First, note that number of solutions to $x^2 = a \mod p$, denoted $N(x^2=a)$, is $1 + \chi(a)$, where $\chi(a) = \left(\frac{a}{p}\right)$ is the Legendre symbol. This allows us to rewrite $N_p(3)$ as a character sum by
$$
\begin{align*}
N_p(3) &= \sum_{a + b+ c = 1} N(x^2 = a) N(x^2 = b) N(x^2 = c) \\
&= \sum_{a+b+c = 1} (1 + \chi(a)) (1 + \chi(b)) (1 + \chi(c))
\end{align*}
$$
Expanding the product, there are three types of terms

*

*"Main term": $\sum_{a+b+c = 1} 1 \equiv 0 \mod p$.

*

*This counts number of solutions to $a+b+c = 1 \mod p$. You can pick anything you like for $a,b$, which then fixes $c = 1 - a - b$, so there's $p^2$ solutions, which is $\equiv 0 \mod p$.



*"Off-diagonal" term: the ones not involving $\chi(a)\chi(b)\chi(c)$. This turns out to be 0. There are two types in this case:

*

*Sums of the form $\sum_{a+b+c = 1} \chi(a)$. Since $\sum_a \chi(a) = 0$, we can sum over $a$ first and get
$$\sum_{a+b+c = 1} \chi(a) = \sum_{a} \chi (a) \sum_{b+c = 1-a} 1 = p^2 \sum_a \chi(a) = 0$$

*Sums of the form $\sum_{a+b+c = 1} \chi(a)\chi(b)$. Similarly,
$$\sum_{a+b+c = 1} \chi(a)\chi(b) = \sum_{a,b} \chi (a) \chi(b) \sum_{c = 1-a-b} 1 = \sum_{a, b} \chi(a)\chi(b) = \left(\sum_a \chi(a)\right)^2 = 0$$



*"Diagonal term": $D_3 = \sum_{a+b+c = 1} \chi(a)\chi(b)\chi(c)$.

*

*This is the most involved case. We will look at the sum
$$D_2 = \sum_{x+y = 1} \chi(x) \chi(y) = -\chi(-1)$$
and
$$E_2 = \sum_{x+y = 0} \chi(x)\chi(y) = (p-1)\chi(-1)$$
When handling $D_3$, sum over $a$ first, so that
$$D_3 = \sum_a \chi(a)\sum_{b+c = 1 - a} \chi(b) \chi(c)$$

*

*When $1 - a = 0$, inner sum is $E_2$.

*When $1 - a \neq 0$, we can write $b = b'(1-a), c = c'(1-a)$, then
$$\chi(b)\chi(c) = \chi(b')\chi(c') \chi(1-a)^2 = \chi(b')\chi(c')$$
since $\chi^2 = 1$ (Legendre symbol), so the inner sum is really $D_2$ in this case.

Hence,
$$D_3 = \chi(1) E_2 + \sum_{a \neq 1} \chi(a) D_2 = E_2 - D_2 = p\chi(-1) \equiv 0 \mod p$$
as well.
