1

The Miller-Rabin test uses k random integers to test for primality.

According to CLRS, 3rd Edition, Page 971:

Theorem 31.38

If n is an odd composite number, then the number of witnesses to the compositeness of n is at least (n - 1)/2.

Then why don't we just instead of running random tests k times, use different ( n - 1 ) / 2 values and test them for primality? Since all primes except 2 are odd and no of witnesses are atleast ( n - 1 ) / 2 we are guaranteed to find a witness if exists.

Community
  • 1
  • 1
Existent
  • 697
  • 1
  • 7
  • 14

1 Answers1

3

The running time goes from poly(log(n)) to n*poly(log(n)), which is terrible for large numbers, since n is exponentially bigger than log(n).

David Eisenstat
  • 64,237
  • 7
  • 60
  • 120
  • But it still uses `k` tests. Is `k` chosen is really small then half of value of number ? What is the value used then? – Existent Jun 06 '16 at 14:11
  • 1
    @ABHI `k` is really small. Miller's original test, which requires the Generalized Riemann Hypothesis, sets k = O(log^2 n). – David Eisenstat Jun 06 '16 at 14:26