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√highcross off a window of the requested range only, so the memory isO(√high + (high − low)). The base sieve dominates the cost for very largehigh(it reaches 2³² nearu64::MAX). - sieve_
of_ eratosthenes - All primes
≤ nby the sieve of Eratosthenes over odd numbers only (n/16bytes of work space as a bit set), inO(n log log n)time.