5. Find the prime $p$ for which 10 is a quadratic residue.
5. Solution: We have
$$\left(\frac{10}{p}\right)=\left(\frac{2}{p}\right)\left(\frac{5}{p}\right)$$

By Example 2 of this chapter, we have

And by Theorem 9, we have
$$\begin{array}{l}
\left(\frac{5}{p}\right)=\left\{\begin{array}{ll}
1, & p \equiv \pm 1(\bmod 5), \\
-1, & p \equiv \pm 2(\bmod 5),
\end{array}\right. \\
\text { and } \\
\left(\frac{2}{p}\right)=\left\{\begin{array}{ll}
1, & p \equiv \pm 1(\bmod 8), \\
-1, & p \equiv \pm 3(\bmod 8) .
\end{array}\right.
\end{array}$$

Solve the following systems of congruences:
$$\begin{array}{l}
\left\{\begin{array}{l}
p \equiv 1(\bmod 5), \\
p \equiv 1(\bmod 8),
\end{array}, \begin{array}{l}
p \equiv 1(\bmod 5), \\
p \equiv-1(\bmod 8)
\end{array},\left\{\begin{array}{l}
p \equiv-1(\bmod 5) \\
p \equiv 1(\bmod 8),
\end{array}\right.\right. \\
\left\{\begin{array}{l}
p \equiv-1(\bmod 5), \\
p=-1(\bmod 8) .
\end{array}\right.
\end{array}$$

We get
$$\begin{array}{l}
p \equiv 1(\bmod 40), p \equiv 31(\bmod 40), p \equiv 9(\bmod 40) \\
p \equiv-1(\bmod 40),
\end{array}$$
Thus, for $p \equiv \pm 1, \pm 9(\bmod 40)$, we have $\left(\frac{10}{p}\right)=1$.
Solve the following systems of congruences:
$$\begin{array}{l}
\left\{\begin{array}{l}
p \equiv 2(\bmod 5), \\
p \equiv 3(\bmod 8),
\end{array},\left\{\begin{array}{l}
p \equiv 2(\bmod 5), \\
p \equiv-3(\bmod 8),
\end{array},\left\{\begin{array}{l}
p \equiv-2(\bmod 5) \\
p \equiv 3(\bmod 8),
\end{array}\right.\right.\right. \\
\left\{\begin{array}{l}
p \equiv=-2(\bmod 5), \\
p \equiv-3(\bmod 8) .
\end{array}\right.
\end{array}$$

We get $p \equiv 27,-3,3,-27(\bmod 40)$, and thus we also know that when $p= \pm 27, \pm 3$, we have $\left(\frac{10}{p}\right)=1$.
Therefore, we conclude that if and only if
$$p \equiv \pm 1, \pm 3, \pm 9, \pm 13,(\bmod 40)$$

$p$ has 10 as a quadratic residue. Similarly, we can prove that if and only if
$$p \equiv \pm 7, \pm 11, \pm 17, \pm 19(\bmod 40)$$

$p$ has 10 as a quadratic non-residue.