diff --git a/bignum-next-prime.c b/bignum-next-prime.c index 51481a71fad0bb8bf113713bd0e0a09abc5bf495..5b30d0f8343cac9cc6f6fa0675f8e0b6097a6601 100644 --- a/bignum-next-prime.c +++ b/bignum-next-prime.c @@ -47,6 +47,9 @@ # define UNLIKELY(cond) cond #endif +/* From some benchmarking using the examples nextprime(200!) and + nextprime(240!), it seems that it pays off to use a prime list up + to around 5000--10000 primes. */ static const unsigned primes[] = { #if 0 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, @@ -62,7 +65,7 @@ static const unsigned primes[] = { 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997 -#elif 0 +#elif 1 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, @@ -231,6 +234,7 @@ bignum_next_prime(mpz_t p, mpz_t n, unsigned count, unsigned prime_limit, if (progress) progress(progress_ctx, '.'); +#if 1 /* FIXME: I doubt this Fermat test saves any time. */ /* Fermat test, with respect to 2 */ mpz_set_ui(tmp, 2); @@ -242,7 +246,7 @@ bignum_next_prime(mpz_t p, mpz_t n, unsigned count, unsigned prime_limit, continue; } - +#endif if (progress) progress(progress_ctx, '+');