Image TOPICS
Image
Search

Rabin-Miller Strong Pseudoprime Test


The Rabin-Miller strong pseudoprime test is a probabilistic primality test based on the properties of strong pseudoprimes. It efficiently detects composite numbers, while an odd prime number always passes.

The algorithm proceeds as follows. Given an odd integer n>=3, let n=2^rs+1, where r is a positive integer and s is odd. Then choose an integer a uniformly at random with 1<=a<=n-1. If a^s=1 (mod n) or a^(2^js)=-1 (mod n) for some integer j satisfying 0<=j<=r-1, then n passes the test. A prime will pass the test for all a. If neither condition holds, n is a composite number.

The test requires O(lgn) modular multiplications per base, where lg is the logarithm base 2. A number which passes the test is not necessarily a prime number. Monier (1980) and Rabin (1980) showed that an odd composite number passes the test for at most 1/4 of the possible bases a. For a fixed composite number, N independent uniform choices of a therefore have probability at most 4^(-N) of all passing, where N is a positive integer.

If the smallest composite number passing a fixed set of bases is known, those bases give a deterministic primality test below that bound, with candidates equal to a prime number used as a base accepted separately. The sequence of smallest odd composite numbers passing a multiple Rabin-Miller test using the first k primes for k=1, 2, ... is 2047, 1373653, 25326001, 3215031751, 2152302898747, 3474749660383, 341550071728321, 341550071728321, ... (OEIS A014233; Jaeschke 1993). Thus the bases 2, 3, 5, 7, 11, 13, and 17 suffice below 341550071728321. Adding base 19 does not increase this bound. The probability bound 4^(-N) applies to independent uniformly random bases and does not apply to a fixed list of bases.

The documented Wolfram Language implementation of PrimeQ[n] first checks divisibility by small primes, then applies this test in bases 2 and 3 and a Lucas pseudoprime test. No composite number is known to pass this combined procedure. Its correctness for all positive integers is unproved.


See also

Baillie-PSW Primality Test, Lucas-Lehmer Test, Miller's Primality Test, Primality Test, Pseudoprime, Strong Pseudoprime

Explore with Wolfram|Alpha

References

Arnault, F. "Rabin-Miller Primality Test: Composite Numbers Which Pass It." Math. Comput. 64, 355-361, 1995.Crandall, R. and Pomerance, C. Prime Numbers. New York: Springer-Verlag, 2001.Damgård, I.; Landrock, P.; and Pomerance, C. "Average Case Error Estimates for the Strong Probable Prime Test." Math. Comput. 61, 177-194, 1993. https://doi.org/10.1090/S0025-5718-1993-1189518-9.Jaeschke, G. "On Strong Pseudoprimes to Several Bases." Math. Comput. 61, 915-926, 1993. https://doi.org/10.1090/S0025-5718-1993-1192971-8.Miller, G. "Riemann's Hypothesis and Tests for Primality." J. Comp. Syst. Sci. 13, 300-317, 1976.Monier, L. "Evaluation and Comparison of Two Efficient Probabilistic Primality Testing Algorithms." Theor. Comput. Sci. 12, 97-108, 1980. https://doi.org/10.1016/0304-3975(80)90007-9.Pomerance, C.; Selfridge, J. L.; and Wagstaff, S. S. Jr. "The Pseudoprimes to 25·10^9." Math. Comput. 35, 1003-1026, 1980. https://doi.org/10.1090/s0025-5718-1980-0572872-7.Rabin, M. O. "Probabilistic Algorithm for Testing Primality." J. Number Th. 12, 128-138, 1980. https://doi.org/10.1016/0022-314X(80)90084-0.Sloane, N. J. A. Sequence A014233 in "The On-Line Encyclopedia of Integer Sequences."Wagon, S. "Primality Testing." Math. Intell. 8, No. 3, 58-61, 1986.Wagon, S. Mathematica in Action. New York: W. H. Freeman, pp. 15-17, 1991.Wolfram Research. "Some Notes on Internal Implementation." https://reference.wolfram.com/language/tutorial/SomeNotesOnInternalImplementation.html.

Referenced on Wolfram|Alpha

Rabin-Miller Strong Pseudoprime Test

Cite this as:

Weisstein, Eric W. "Rabin-Miller Strong Pseudoprime Test." From MathWorld--A Wolfram Resource. https://mathworld.wolfram.com/Rabin-MillerStrongPseudoprimeTest.html

Subject classifications