Skip to main content

Section 5.6 Wilson's Theorem

Wilson's theorem is one of the few "if and only if" statements about primes.

\((\Rightarrow)\) For \(p = 2, 3\) the theorem is clear. Now suppose that \(p\gt 3,\) and that

\begin{equation*} a\in \{1, 2, 3,..., p-1\}. \end{equation*}

Note that \(\gcd(p, a) = 1\) for such \(a.\) By a previous theorem the inverse of \(a\) is unique. Also if \(a\) is its own inverse, we know that \(a^2\equiv 1\pmod{p}\) so that

\begin{equation*} (a + 1)(a-1) \equiv 0\pmod{p}, \end{equation*}

and so \(a = 1\) or \(a = p-1.\) Thus the set

\begin{equation*} A = \{2, 3, 4,..., p-2\} \end{equation*}

is a set of even numbers such that if \(a\in A,\) then \(a^{-1}\in A,\) and \(a\neq a^{-1}.\) This gives

\begin{equation*} 2\cdot 3...(p-2)\equiv 1 \pmod{p}, \end{equation*}

which is the same as

\begin{equation*} (p-2)! \equiv 1\pmod{p}, \end{equation*}

so that multiplying by \(p-1\) on both sides gives

\begin{equation*} (p-1)! \equiv -1\pmod{p}. \end{equation*}

\((\Leftarrow)\) Suppose \((n-1)!\equiv -1\pmod{n},\) and \(n\) is not prime. Then there is a divisor \(d\gt 1\) of \(n.\) Now if \(n\vert (n-1)! + 1,\) then \(d\vert (n-1)! + 1,\) so that since \(d\vert (n-1)!\) we have that \(d\vert 1,\) which is absurd. Thus \(n\) is prime.