GMP issue with mpz_nextprime()

simondev1 scavegn at
Mon Jan 13 18:21:34 UTC 2020

Dear gmp developer,

Found non-prime with method mpz_nextprime:

GMP Version 4.31(probably)
Compiled into a 64bit windows DLL

p = 2028576353201;
mpz_nextprime(p, p); // this will find 2028576353203 which is not prime.
I assume the number of repetitions for the probablyprime test inside mpz_nextprime() is too low. Probablyprime with 5 repetitions say its probably a prime, 6 repetitions already find this number is not a prime. Suggestion would be increase the number of repetitions from about 5 to about 7..20? And add an overload where one can specify number of repetitions? (Some apps need speed, some need certainity.)
Or add 2028576353203 (and the number of repetitions) to documentation of mpz_nextprime().

Best Regards,
Simon Cavegn

More information about the gmp-bugs mailing list