Wilson's Theorem/Necessary Condition/Proof 1

Proof
If $p = 2$ the result is obvious.

Therefore we assume that $p$ is an odd prime.

Let $p$ be prime.

Consider $n \in \Z, 1 \le n < p$.

As $p$ is prime, $n \perp p$.

From Law of Inverses (Modulo Arithmetic), we have:


 * $\exists n' \in \Z, 1 \le n' < p: n n' \equiv 1 \pmod p$

By Solution of Linear Congruence, for each $n$ there is exactly one such $n'$, and $\paren {n'}' = n$.

So, provided $n \ne n'$, we can pair any given $n$ from $1$ to $p$ with another $n'$ from $1$ to $p$.

We are then left with the numbers such that $n = n'$.

Then we have $n^2 \equiv 1 \pmod p$.

Consider $n^2 - 1 = \paren {n + 1} \paren {n - 1}$ from Difference of Two Squares.

So either $n + 1 \divides p$ or $n - 1 \divides p$.

Observe that these cases do not occur simultaneously, as their difference is $2$, and $p$ is an odd prime.

From Congruence Modulo Negative Number‎, we have that $p - 1 \equiv -1 \pmod p$.

Hence $n = 1$ or $n = p - 1$.

So, we have that $\paren {p - 1}!$ consists of numbers multiplied together as follows:


 * in pairs whose product is congruent to $1 \pmod p$
 * the numbers $1$ and $p - 1$.

The product of all these numbers is therefore congruent to $1 \times 1 \times \cdots \times 1 \times p - 1 \pmod p$ by modulo multiplication.

From Congruence Modulo Negative Number we therefore have that $\paren {p - 1}! \equiv -1 \pmod p$.