What's the number of solutions of the quadratic equation $x_1^2+\dots+x_m^2=0$ over finite ring $\mathbb{Z}/p^n$? I want to calculate the number of solutions to the quadratic equation $$x_1^2+\dots+x_m^2=0$$ where $m$ is odd (a given number) and $x_i\in\mathbb{Z}/p^n$ for a given prime number $p$ and a given positive integer $n$.
I guess one can consider the projective variety over the $p$-adic field $\mathbb{Q}_p$ and count the point of some kind of projection but I didn't make it.
 A: For what it's worth, if you want to investigate this more generally, let $f(x_1,\ldots,x_m)\in\mathbb Z[x_1,\ldots,x_m]$ be a homogeneous form of degree $d$, and let
$$ N_n(f) = \Bigl(\text{# of solutions of } f(x_1,\ldots,x_m)\equiv0\pmod{p^n}\Bigr). $$
Then the Igusa zeta function of $f$ is (more-or-less) the generating function
$$ Z(f,t) = \sum_{n=1}^\infty N_n(f) (t/p^m)^n . $$
A deep theorem of Igusa, with a subsequent alternative proof by Denef, say that $Z(f,t)$ is a rational function, but exact formulas are known in only a small number of cases. However, one case where a lot is known is "Fermat-type equations," i.e., diagonal equations, of which yours is the first interesting example.
A: Let $G$ be a cyclic group of order $N=p^n$, $g$ its generator. You ask for the constant term in the expression $(\sum_{k=0}^{N-1} g^{k^2})^m$ in the group ring, say, $\mathbb{C}[G]$. By roots of unity filter it equals
$$
\frac1N\sum_{w^N=1} \left(\sum_{k=0}^{N-1} w^{k^2}\right)^m.
$$
This reduces the question to quadratic Gauss sums which were computed by Gauss.
Let me concentrate on $N=2^n$ case which is more difficult and not covered by YCor's answer (UPDATE: already covered). Denote $w=\exp(a2^s\frac{2\pi i}{2^n})$ for $s=0,1,\ldots,n$ odd $a\in \{1,3,\ldots,2^{n-s}-1\}$. For $f(w):=\sum_{k=0}^{N-1} w^{k^2}$ we get $f(1)=N$ (this contributes to $s=n$ case, $f(-1)=0$ (this contributes to $s=n-1$ case), for $s\leqslant n-2$ we get $f(w)=2^sG(a,0,2^{n-s})$ in Wiki notation, and the formula gives $$G(a,0,2^{n-s})=(1+i)\varepsilon_a^{-1}\sqrt{2^{n-s}}\left(\frac{2^{n-s}}a\right).$$
It is not hard to sum up $m$-th powers of such guys for each fixed $s$. There are several similar cases in dependence on parity of $m$ and $n-s$.

*

*$m=4k+2$. The sum over $a$ does vanish as $\varepsilon_a^2$ alternate.


*$m=4k$. The sum over $a$ equals $(-4)^k2^{2k(n-s)}$.


*$m$ is odd and $n-s$ is odd. The sum over $a$ does vanish as $\varepsilon_a^{-1}(\frac{2}a)$ takes teh values $\pm 1$, $\pm i$ equally often.


*$m$ is odd and $n-s$ is even. The sum over $a$ equals
$$
2^{ms}(1+i)^m2^{n-s-2}(1+i^{-m})2^{(n-s)m/2}.
$$
It remains to sum up over $s=0,1,\ldots,n-2$, the sum is a geometric progression in both non-trivial cases.
