1911 Encyclopædia Britannica/Number/The Theorems of Fermat and Wilson

28. The Theorems of Fermat and Wilson.&mdash;Let $$r_1, r_2, \dots r_t$$ where $$t=\phi(m)$$, be a complete set of residues prime to the modulus $$m$$. Then if $$x$$ is any number prime to $$m$$, the residues $$xr_1, xr_2, \dots xr_t$$ also form a complete set prime to $$m$$ (&sect; 27). Consequently $$xr_1\cdot xr_2, \dots xr_t \equiv r_1r_2 \dots r_t$$, and dividing by $$r_1r_2 \dots r_t$$, which is prime to the modulus, we infer that
 * $$x^{\phi(m)}\equiv 1 \pmod{m}$$

which is the general statement of Fermat's theorem. If $$m$$ is a prime $$p$$, it becomes $$x^{p-1} \equiv 1 \pmod{p}$$.

For a prime modulus $$p$$ there will be among the set $$x, 2x, 3x, \dots (p-l)x$$ just one and no more that is congruent to $$1$$: let this be $$xy$$. If $$y \equiv x$$, we must have $$x^2 - 1 = (x-1)(x+1)\equiv 0$$, and hence $$x \equiv \pm 1$$: consequently the residues $$2, 3, 4, ... (p-2)$$ can be arranged in $$\tfrac{1}{2}(p-3)$$ pairs $$(x, y)$$ such that $$xy \equiv 1$$. Multiplying them all together, we conclude that $$2.3.4. \dots (p-2) \equiv l$$ and hence, since $$1.(p-1) \equiv -1$$,
 * $$(p-1)! \equiv -1 \pmod{p}$$.

which is Wilson's theorem. It may be generalized, like that of Fermat, but the result is not very interesting. If $$m$$ is composite $$(m-1)! + 1$$ cannot be a multiple of $$m$$: because $$m$$ will have a prime factor $$p$$ which is less than $$m$$, so that $$(m-1)!\equiv 0 \pmod {p}$$. Hence Wilson’s theorem is invertible: but it does not supply any practical test to decide whether a given number is prime.