# Wilson's theorem

In 1770 Edward Waring announced the following theorem by his former student John Wilson.

**Wilson's Theorem.**- Let
*p*be an integer greater than one.*p*is prime if and only if (*p*−1)! ≡ −1 (mod*p*).

This beautiful result is of mostly theoretical value because it is relatively difficult to calculate
(*p*−1)! In contrast it is easy to calculate
*a*^{p−1}, so elementary
primality tests are built using Fermat's Little
Theorem rather than Wilson's Theorem. For example,
the largest prime ever shown prime by Wilson's theorem
is most likely 1099511628401, and even with a clever approach to calculating *n*!, this still took
about one day on a SPARC processor. But numbers
with ten's of thousands of digits have been shown prime using a converse of Fermat's theorem in a less than an hour.

You might want to try your hand at proving the following corollary to Wilson's theorem:
*n* is prime if and only if
sin(((*n*−1)!+1)pi/*n*) is zero.

**See Also:** WilsonPrime

**Related pages** (outside of this work)

**References:**

- CDP97
R. Crandall,K. DilcherandC. Pomerance, "A search for Wieferich and Wilson primes,"Math. Comp.,66:217 (1997) 433--449.MR 97c:11004(Abstract available)