private static BitArray MakeSieve(PrimeNumbers primes, int until) { until++; var bits = new BitArray(until); bits[0] = true; bits[1] = true; foreach (var prime in primes.Until((int)Math.Sqrt(until))) { for (int i = prime * 2; i < until; i += prime) { bits[i] = true; } } return(bits.Not()); }
public PrimeNumbers(PrimeNumbers primes, int until) : this(MakeSieve(primes, until)) { }