var blob = use('blob')

function eratosthenes (n) {
  var sieve = new blob(n, true)
  var sqrtN = Math.trunc(Math.sqrt(n));

  for (i = 2; i <= sqrtN; i++)
    if (sieve.read_logical(i))
      for (j = i * i; j <= n; j += i)
          sieve.write_bit(j, false);
          
  return sieve;
}

var sieve = eratosthenes(10000000);
stone(sieve)

var c = 0
for (var i = 0; i < sieve.length; i++)
  if (sieve.read_logical(i)) c++
  
log.console(c)

$_.stop()