Elysia Tools

Browse tools, examples, visual explainers, and topic guides from one clear workspace.

Top Categories

Hubs

Language
ZHDERUPTENFRES

Elysia Tools

Navigation

Math & Numbers

Wilson's Theorem Primality Checker

· Last updated:2026-08-28

(n−1)! ≡ −1 (mod n) ⟺ n is prime. Exact factorial residue for n ≤ 10⁷, Miller–Rabin cross-check, composite factorial law, optional running-products trace.

Execution

Run this tool

Fill in the form, run the tool, and review the result in one place.

Samples

Examples that match this tool

Related

Continue with connected tools and hubs

Written by the Elysia Tools team

Tool usage guide

Learn when to use this tool, what it supports, and how real users apply it.

Key facts

Category
Math & Numbers
Input types
text, select
Output type
text
Sample coverage
4
API ready
Yes

Overview

The Wilson's Theorem Primality Checker evaluates whether an integer n is prime by computing the factorial residue (n−1)! modulo n. It tests the classical congruence (n−1)! ≡ −1 (mod n), cross-checks the result using deterministic Miller–Rabin, evaluates the composite factorial law, and optionally outputs running modular products.

When to use

  • Verifying primality for integers up to 10⁷ using exact Wilson's theorem modular reduction.
  • Studying step-by-step modular residue sequences k! mod n for educational or number theory demonstrations.
  • Demonstrating the composite factorial law where (n−1)! ≡ 0 (mod n) for composite numbers greater than 4.

How it works

  1. 1Enter an integer n within the supported range (2 ≤ n ≤ 10⁷) and choose the desired output detail level.
  2. 2The tool iteratively multiplies k from 1 to n−1 modulo n to compute the exact residue of (n−1)! mod n.
  3. 3It checks if the residue equals n − 1 (representing −1 mod n) and applies deterministic Miller–Rabin to provide an independent cross-check.

Use cases

  • Number theory students inspecting the sequence of running products k! mod n to observe modular multiplicative inverses.
  • Mathematics educators verifying primality test proofs with deterministic cross-checking.
  • Developers validating modular arithmetic implementations against verified mathematical theorems.

Examples

1. Verifying a prime with running products

Mathematics Student

Background

A student is analyzing how modular inverses pair up during the factorial accumulation modulo a prime.

Problem

Check if 13 is prime using Wilson's theorem and examine the step-by-step product trace.

How to use

Enter 13 into the Number n field and select 'Also show running products (n ≤ 200)' in Output detail.

n = 13, detail = trace

Outcome

Shows 12! mod 13 = 12, confirms Wilson's condition holds, lists all 12 intermediate products, and confirms primality via Miller–Rabin.

2. Checking a composite number under the factorial law

Math Educator

Background

A teacher is preparing lecture materials demonstrating why composites collapse to 0 modulo n.

Problem

Evaluate n = 9 to show that Wilson's congruence fails and the composite factorial law holds.

How to use

Enter 9 into the Number n field and select 'Verdict and cross-check'.

FAQ

What is Wilson's theorem?

Wilson's theorem states that a natural number n > 1 is prime if and only if (n−1)! ≡ −1 (mod n).

Why does the tool limit running products to n ≤ 200?

Generating and displaying the full list of intermediate residues k! mod n is restricted to n ≤ 200 to keep the output readable and performant.

What is the composite factorial law?

For every composite number n > 4, (n−1)! ≡ 0 (mod n) because its factors appear before reaching n−1.

Why is Wilson's theorem rarely used for massive cryptographic primes?

Computing (n−1)! takes O(n) modular operations, which becomes computationally infeasible for very large numbers compared to O(log n) tests like Miller–Rabin.

What is the only composite exception where (n−1)! is not 0 mod n?

The only composite exception is n = 4, where (4−1)! = 3! = 6 ≡ 2 (mod 4).

Home
Tools3212
Samples593
Visualizations471
Viewers103
Hubs239
Tags333
Images, Audio & Video657

Image, audio, and video processing, conversion, and optimization tools

Math, Date & Finance647

Calculators, numerics, date logic, statistics, and finance tools

Design & Color298

Color, layout, graphics, visual styling, and design helper tools

Text & Writing209

Writing, cleanup, formatting, extraction, and text analysis tools

Developer & Web193

Developer utilities, networking, web debugging, and automation helpers

Conversion & Encoding175

Format, file, archive, unit, and encoding conversion tools

Lead Generation Quiz Launch and Contact Handoff
Memorial Drafts: Family Review and Print Handoff
Private Habit Records: Backup, Restore and Sharing Review
Article to X and LinkedIn Drafts: Fact Review and Handoff
Markdown Interactive Deck Review and Offline Handoff

© 2026 Elysia Tools. All rights reserved.

DocsPricingAboutTerms of ServicePrivacy PolicyCookiesContact
Java

Android Image Processing Java Samples

Android Java image processing examples including reading/saving images, scaling, and format conversion

Kotlin

Android Image Processing Kotlin Samples

Android Kotlin image processing examples including reading/saving images, scaling, and format conversion

Python

Web Image Processing Python Samples

Web Python image processing examples using PIL/Pillow including reading, saving, resizing, and format conversion

Rust

Web Image Processing Rust Samples

Web Rust image processing examples including image read/save, scaling, and format conversion

Math & Numbers

Perfect Number Checker

σ(n) = 2n ⟺ perfect. Factorization-based σ(n), proper-divisor sum, deficient/perfect/abundant classification, abundancy index, Euclid–Euler form. n ≤ 10¹².

Math & Numbers

Prime Number Checker

Check if a number is prime (a natural number greater than 1 that has no positive divisors other than 1 and itself)

Math & Numbers

Dimensional Analysis Unit Cancellation Tutor

Step-by-step factor-label unit cancellation with inverted-factor diagnosis and optional student-answer checking.

Math & Numbers

PERT Network Analyzer (Expected Duration & Variance)

Three-point PERT estimates: te and σ² per activity, critical path, expected project duration and variance, and normal completion probability for a target time.

n = 9, detail = verdict

Outcome

Outputs 8! mod 9 = 0, confirms 0 ≠ 8 (fails Wilson's test), and validates the composite factorial law.