Miller-Rabin Primality Test Visualizer
Test a Number for Primality
The Miller-Rabin test is a probabilistic algorithm to determine if a number is probably prime.
(More iterations = more accurate)
How the Miller-Rabin Test Works
- Decompose n-1 into d × 2s
- For each iteration:
- Pick a random base a between 2 and n-2
- Compute x = ad mod n
- If x ≡ 1 or x ≡ n-1, continue to next iteration
- Otherwise, square x up to s-1 times
- If none of these squares ≡ n-1, then n is composite
- If all iterations pass, n is probably prime
0 Comments