Modular Arithmetic/Wilson's Theorem

 Modular Arithmetic ← Lagrange's Theorem Wilson's Theorem Chinese Remainder Theorem →
Wilson's theorem

A natural number ${\displaystyle \alpha \neq 1}$ is a prime number if and only if:

${\displaystyle (\alpha -1)!\equiv -1{\pmod {\alpha }}}$
${\displaystyle \alpha !}$ denotes the factorial of ${\displaystyle \alpha }$ . For all natural numbers, it gives the product of all numbers less than or equal to ${\displaystyle \alpha }$ .

Examples

5 is a prime number because,

${\displaystyle 4!=24}$

and

${\displaystyle 24\equiv -1{\pmod {5}}\implies 25|5}$

which is true. 6, on the other hand, is not, as

${\displaystyle 5!=120}$

and

${\displaystyle 120\equiv -1{\pmod {6}}\implies 121|6}$

which is false.