/* find all primes under a certain N */

var i,
    j,
    N=200000,
    nonprimes = [],
    primes = [];

for (i = 2; i <=N; i++) {
  for (j = 2*i; j <=N; j+=j) {
   if (nonprimes.indexOf(j) === -1) {
      nonprimes.push(j);
    }
  }
}

for (i=2;i<=N;i++) {
  if (nonprimes.indexOf(i) === -1) {
    primes.push(i);
  }
}
console.log(primes);

dc6b3035dad144ef3bf275650e2f53e4705627c0
/* find all primes under a certain N */

var i,
    j,
    N=200000,
    nonprimes = [],
    primes = [];

for (i = 2; i <=N; i++) {
  for (j = 2*i; j <=N; j+=j) {
   if (nonprimes.indexOf(j) === -1) {
      nonprimes.push(j);
    }
  }
}

for (i=2;i<=N;i++) {
  if (nonprimes.indexOf(i) === -1) {
    primes.push(i);
  }
}
console.log(primes);
