Miller Rabin Primality test accuracy

前端 未结 5 974
情深已故
情深已故 2021-01-01 01:52

I know the Miller–Rabin primality test is probabilistic. However I want to use it for a programming task that leaves no room for error.

Can we assume that it is corr

5条回答
  •  佛祖请我去吃肉
    2021-01-01 02:06

    For n < 2^64, it is possible to perform strong-pseudoprime tests to the seven bases 2, 325, 9375, 28178, 450775, 9780504, and 1795265022 and completely determine the primality of n; see http://miller-rabin.appspot.com/.

    A faster primality test performs a strong-pseudoprime test to base 2 followed by a Lucas pseudoprime test. It takes about 3 times as long as a single strong-pseudoprime test, so is more than twice as fast as the 7-base Miller-Rabin test. The code is more complex, but not dauntingly so.

    I can post code if you're interested; let me know in the comments.

提交回复
热议问题