I had a quick look at the mpz_nextprime code. While I noticed the new code which is not yet enabled, it surprised me how naïve the current implementation is.<br><br>void<br>mpz_nextprime (mpz_ptr p, mpz_srcptr t)<br>{<br> mpz_add_ui (p, t, 1L);
<br> while (! mpz_probab_prime_p (p, 5))<br> mpz_add_ui (p, p, 1L);<br>}<br><br><br>You can easily get a 2x speedup just by doing:<br><br>void<br>mpz_nextprime (mpz_ptr p, mpz_srcptr t)<br>{<br> mpz_add_ui (p, t, 1L);
<br> mpz_setbit(p, 0);<br> while (! mpz_probab_prime_p (p, 5))<br> mpz_add_ui (p, p, 2L);<br>}<br><br>This probably is like it is for a reason, but I just wanted to give my input on this<br><br>Best Regards,<br>Rob Holmes
<br>