示例#1
0
        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());
        }
示例#2
0
 public PrimeNumbers(PrimeNumbers primes, int until) : this(MakeSieve(primes, until))
 {
 }