Wilson Theorem Calculator
Work out wilson theorem instantly with clear inputs, formula shown and shareable results.
About Wilson Theorem Calculator
Wilson's theorem gives an exact primality criterion: p is prime if and only if (p − 1)! ≡ −1 (mod p). It is beautiful but useless for large p, since computing the factorial is far slower than trial division.
Formula
Wilson's theorem
(p − 1)! ≡ −1 (mod p) ⇔ p is prime
Worked example
With the default values below, Wilson Theorem Calculator returns (p−1)! mod p of 12. Change any input above and every figure here is recalculated in your browser.
Inputs used
- Number to testaccepts 2–500
- 13
- Also testaccepts 2–500
- 15
Results
- (p−1)! mod p
- 12
- Interpretation
- 13 is prime — (p−1)! ≡ −1 (mod p)
- Value expected for a prime (p − 1)
- 12
- (p−1)! mod p for the second number
- 0
Step by step
- 1Values used
- 2Wilson's theorem
- 3(p−1)! mod p= 12
- 4Interpretation= 13 is prime — (p−1)! ≡ −1 (mod p)
- 5Value expected for a prime (p − 1)= 12
- 6(p−1)! mod p for the second number= 0
Assumptions and limits
- The result is derived only from the 2 inputs listed above. Anything not among them is not part of the calculation.
- In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
- Figures are rounded for display to whole numbers, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.
How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.
Frequently Asked Questions
Check 13.
12! mod 13 = 12, which is −1 mod 13, confirming 13 is prime.
Why does it fail for composites?
For composite p above 4, the factors of p all appear among 1 to p − 1, so the factorial is divisible by p and the residue is 0.
Related Calculators
You might also need
- Fermat Little Theorem CalculatorAlso in Discrete Math, Logic & Number Theory
- Discrete Logarithm CalculatorAlso in Discrete Math, Logic & Number Theory
- Adjacency Matrix CalculatorAlso in Discrete Math, Logic & Number Theory
- Base 64 Value CalculatorAlso in Discrete Math, Logic & Number Theory
- Bell Number CalculatorAlso in Discrete Math, Logic & Number Theory
- Binary To Decimal CalculatorAlso in Discrete Math, Logic & Number Theory
