[step:Alternative proof via a primitive root]
We record a second proof as an independent verification. By the theorem that [$(\mathbb{Z}/p\mathbb{Z})^\times$ is Cyclic](/theorems/1710), there exists a generator $g$ of $(\mathbb{Z}/p\mathbb{Z})^\times$, so
\begin{align*}
(\mathbb{Z}/p\mathbb{Z})^\times = \{1, g, g^2, \ldots, g^{p-2}\},
\end{align*}
with these $p - 1$ elements pairwise distinct. An element $a \in (\mathbb{Z}/p\mathbb{Z})^\times$ is a quadratic residue iff $a = x^2$ for some $x \in (\mathbb{Z}/p\mathbb{Z})^\times$. Writing $x = g^k$ with $0 \le k \le p - 2$, we have $a = g^{2k}$. Hence
\begin{align*}
\{\text{quadratic residues}\} = \{g^{2k} \bmod p^{p-1} : 0 \le k \le p - 2\} = \{g^{2k \bmod (p-1)} : 0 \le k \le p - 2\}.
\end{align*}
As $k$ ranges over $\{0, 1, \ldots, p-2\}$, the exponent $2k \bmod (p-1)$ ranges over the even residues mod $p - 1$. Since $p - 1$ is even (as $p$ is odd), the even residues are exactly $\{0, 2, 4, \ldots, p - 3\}$, giving $(p-1)/2$ distinct values. The corresponding elements $g^0, g^2, g^4, \ldots, g^{p-3}$ are pairwise distinct because distinct exponents mod $p - 1$ give distinct powers of $g$.
Thus the number of quadratic residues is $(p - 1)/2$, in agreement with the first proof.
[/step]