98 extern unsigned long next_prime(
unsigned long n);
133 for (
int i = 2; i <=
sqrt(n); i++)
169 const unsigned long max = std::numeric_limits<unsigned long>::max();
172 <<
"next_prime_number_greater_than: overflow error";
179 <<
"next_prime_number_greater_than: overflow error";
181 unsigned long p = n + 2;
185 <<
"next_prime_number_greater_than: overflow error";
Exception handling system with formatted messages for Aleph-w.
#define ah_domain_error_if(C)
Throws std::domain_error if condition holds.
Core definitions, constants, and utility macros for Aleph-w.
__gmp_expr< typename __gmp_resolve_expr< T, V >::value_type, __gmp_binary_expr< __gmp_expr< T, U >, __gmp_expr< V, W >, __gmp_max_function > > max(const __gmp_expr< T, U > &expr1, const __gmp_expr< V, W > &expr2)
__gmp_expr< T, __gmp_unary_expr< __gmp_expr< T, U >, __gmp_sqrt_function > > sqrt(const __gmp_expr< T, U > &expr)
unsigned long next_prime_number_greater_than(unsigned long n)
Find the next prime strictly greater than n.
const unsigned long primeList[]
Pre-computed array of prime numbers for fast lookup.
const size_t numPrimes
Number of primes in the pre-computed database.
const unsigned long DefaultPrime
Default prime number used when no specific size is requested.
bool check_primes_database()
Verify the integrity of the prime database.
bool is_prime(unsigned long n)
Test if a number is prime using trial division.
size_t next_prime(unsigned long n)
Find the smallest prime number >= n from the database.