Write n−1 = d·2s, pick a base a, compute ad, then square repeatedly watching for 1 and −1. A nontrivial square root of 1 means composite.
step 0
Decomposition & base
Bases tried (proven set up to current n's range):
x0 = ad mod n. If x0 is 1 or −1, this base passes immediately.
value = 1 value = −1 (passes) nontrivial root (witness)
Squaring chain ad, a2d, a4d, …
verdict: pending…
Press Step to begin. We decompose n−1 = d·2s, then run the witness loop for each base. When it says composite, that is a proof.
Self-contained visualization. Uses BigInt-safe modular exponentiation so values stay exact. A witness base proves n composite; passing all proven bases (up to the supported range) certifies n prime.
See junior.md and professional.md for the square-root-of-1 lemma behind the −1 / nontrivial-root checks.