private void GetDivisors(bool[] block)
        {
            // Sieve for all primes < sqrt(size).
            var sublimit = (int)Math.Ceiling(Math.Sqrt(limit));

            primes.AddPrime(2);
            for (var i = 3; i < sublimit; i += 2)
            {
                if (!block[i])
                {
                    for (var j = i * i; j < limit; j += i)
                    {
                        block[j] = true;
                    }
                    primes.AddPrime((uint)i);
                }
            }
            for (var i = sublimit | 1; i < limit; i += 2)
            {
                if (!block[i])
                {
                    primes.AddPrime((uint)i);
                }
            }
            divisors         = primes.FirstBucket;
            numberOfDivisors = primes.Count;
        }
 public PrimeCollection(long size, int threads)
 {
     this.size = Math.Min((long)uint.MaxValue + 1, size);
     limit     = (int)Math.Ceiling(Math.Sqrt(size));
     block     = new bool[Math.Max(blockSizeSingleThreaded >> 1, limit)];
     primes    = new Primes();
     if (size <= 13)
     {
         // Special case for small collections because we handle
         // 2 and 3 differently.
         foreach (var prime in new uint[] { 2, 3, 5, 7, 11 })
         {
             if (size > prime)
             {
                 primes.AddPrime(prime);
             }
         }
     }
     else
     {
         GetDivisors(block);
         CreateCycle();
         GetPrimes(threads);
     }
 }