TOPICS
Search

Rabin-Miller Strong Pseudoprime Test


A primality test that provides an efficient probabilistic algorithm for determining if a given number is prime. It is based on the properties of strong pseudoprimes.

The algorithm proceeds as follows. Given an odd integer n, let n=2^rs+1 with s odd. Then choose a random integer a with 1<=a<=n-1. If a^s=1 (mod n) or a^(2^js)=-1 (mod n) for some 0<=j<=r-1, then n passes the test. A prime will pass the test for all a.

The test is very fast and requires no more than (1+o(1))lgn multiplications (mod n), where lg is the logarithm base 2. Unfortunately, a number which passes the test is not necessarily prime. Monier (1980) and Rabin (1980) have shown that a composite number passes the test for at most 1/4 of the possible bases a. If N multiple independent tests are performed on a composite number, then the probability that it passes each test is 1/4^N or less.

However, if the smallest composite number that passes a particular set of tests is known ahead of time, then that set of tests constitutes a primality proof for all smaller numbers. The sequence of smallest odd numbers passing a multiple Rabin-Miller test using the first k primes for k=1, 2, ... is given by 2047, 1373653, 25326001, 3215031751, 2152302898747, 3474749660383, 341550071728321, 341550071728321, ... (OEIS A014233; Jaeschke 1993). Therefore, multiple Rabin tests using the first 7 primes (using 8 gives no improvement) are valid for every number up to 3.4×10^(14).

The Wolfram Language implements the multiple Rabin-Miller test in bases 2 and 3 combined with a Lucas pseudoprime test as the primality test used by the function PrimeQ[n]. As of 1997, this procedure is known to be correct only for all n<10^(16), but no counterexamples are known and if any exist, they are expected to occur with extremely small probability (i.e., much less than the probability of a hardware error on a computer performing the test).


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 Probably Prime Test." Math. Comput. 61, 177-194, 1993.Jaeschke, G. "On Strong Pseudoprimes to Several Bases." Math. Comput. 61, 915-926, 1993.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.Pomerance, C.; Selfridge, J. L.; and Wagstaff, S. S. Jr. "The Pseudoprimes to 25·10^9." Math. Comput. 35, 1003-1026, 1980. http://mpqs.free.fr/ThePseudoprimesTo25e9.pdf.Rabin, M. O. "Probabilistic Algorithm for Testing Primality." J. Number Th. 12, 128-138, 1980.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.

Referenced on Wolfram|Alpha

Rabin-Miller Strong Pseudoprime Test

Cite this as:

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

Subject classifications