= Solution
Suppose $X^2\equiv-1\pmod p$. Then $X$ is a <unit modulo n> for modulus $p$, and <Fermat's little theorem> implies
$$
1\equiv X^{p-1}=(X^2)^{(p-1)/2}\equiv(-1)^{(p-1)/2}\pmod p.
$$
Since $p$ is an odd <prime number>, $1$ and $-1$ are distinct <residue classes>. Therefore $(p-1)/2$ is even, and $p\equiv1\pmod4$.
Conversely, put $q=(p-1)/2$. Pair each <integer> $j\in\{1,\ldots,q\}$ with $p-j$ in the <factorial>. <Wilson theorem> yields
$$
-1\equiv(p-1)!=\prod_{j=1}^q j(p-j)\equiv(-1)^q(q!)^2\pmod p.
$$
When $p\equiv1\pmod4$, $q$ is even, so $X=q!$ satisfies $X^2\equiv-1\pmod p$. This proves the <first supplementary law for quadratic reciprocity> without assuming a primitive root. Hence
$$
\boxed{X^2\equiv-1\pmod p\text{ is solvable exactly when }p\equiv1\pmod4.}
$$
The two solutions are $q!$ and $-q!$ modulo $p$: their difference is nonzero, and factoring $X^2-Y^2$ shows that a degree-two <polynomial> over the <field> of residues modulo $p$ has no further roots.
Back to article page