Skip to main content

Module prime_sieves

Module prime_sieves 

Source
Expand description

Prime sieves.

See the book entry Primes: sieves, Miller–Rabin and factorisation.

Functions§

prime_count
The prime-counting function π(n).
segmented_sieve
All primes in [low, high] by a segmented sieve: base primes up to √high cross off a window of the requested range only, so the memory is O(√high + (high − low)). The base sieve dominates the cost for very large high (it reaches 2³² near u64::MAX).
sieve_of_eratosthenes
All primes ≤ n by the sieve of Eratosthenes over odd numbers only (n/16 bytes of work space as a bit set), in O(n log log n) time.