These are chat archives for **camperbot/bonfire-sum-all-primes**

function getPrimes(max) {

var sieve = [];

var i;

var j;

var primes = [];

for (i = 2; i <= max; ++i) {

if (!sieve[i]) {

// i has not been marked -- it is prime

primes.push(i);

for (j = i << 1; j <= max; j += i) {

sieve[j] = true;

}

}

}

`return primes;`

}

I cannot figure out how the prime works

how can the function determine which numbers between 2~the max num is a prime

I understand it start from 2

but is it ++i equals to i++?