Overview
Miller-Rabin writes n - 1 as 2^s d and checks whether chosen bases behave like they should modulo a prime. A failing base proves compositeness; enough independent bases make a probable-prime result reliable for practical prime generation.
Tests whether an integer is probably prime by looking for modular witnesses of compositeness.
Compact metadata for implementation and discovery.
Miller-Rabin writes n - 1 as 2^s d and checks whether chosen bases behave like they should modulo a prime. A failing base proves compositeness; enough independent bases make a probable-prime result reliable for practical prime generation.
Quick facts
Runtime and memory behavior at a glance.
Best
O(k)
Average
O(k^2)
Worst
O(k^3)
Space
O(k)
check a^d mod n and a^(2^r*d) mod n for r = 0..s-1Looks for modular powers that prove compositeness.
Show checking whether random bases witness compositeness on a small probabilistic primality testing example.
A composite result is certain; a probable-prime result depends on the base policy.
What each reference supports for this entry.
Cryptographic reference for Miller-Rabin Primality Test's number-theoretic primitive, modular arithmetic, primality, or factorization context.
Open sourceReference for Miller-Rabin Primality Test's arithmetic operations, modular arithmetic, multiplication, division, or number-theoretic implementation details.
Open sourceGood next jumps from the relationship graph, ranked for useful discovery.
Numerical Methods · Foundation
Miller-Rabin tests individual large candidates rather than enumerating all primes up to a limit.
Compare with thisCryptography · Core
Miller-Rabin strengthens Fermat testing by checking the square-root chain modulo n.
Compare with thisCryptography · Core
Barrett reduction is another way to keep modular powers efficient during witness tests.
Compare with thisMiller-Rabin strengthens Fermat testing by checking the square-root chain modulo n.
Large modular exponentiations in Miller-Rabin can use Montgomery multiplication for speed.
Barrett reduction is another way to keep modular powers efficient during witness tests.