*** Welcome to piglix ***

Wilson's theorem


In number theory, Wilson's theorem states that a natural number n > 1 is a prime number if and only if

That is, it asserts that the factorial is one less than a multiple of n exactly when n is a prime number.

This theorem was stated by Ibn al-Haytham (c. 1000 AD), and John Wilson.Edward Waring announced the theorem in 1770, although neither he nor his student Wilson could prove it. Lagrange gave the first proof in 1771. There is evidence that Leibniz was also aware of the result a century earlier, but he never published it.

The following table shows the values of n from 2 to 30, (n − 1)!, and the remainder when (n − 1)! is divided by n. (In the notation of modular arithmetic, the remainder when m is divided by n is written m mod n.) The background color is blue for prime values of n, gold for composite values.

Both of the proofs (for prime moduli) below make use of the fact that the residue classes modulo a prime number are a field—see the article prime field for more details. Lagrange's theorem, which states that in any field a polynomial of degree n has at most n roots, is needed for both proofs.


...
Wikipedia

...