How does Sieve work? #SumAllPrimes

I am trying to understand the ‘basic’ solution but I don’t understand how the Sieve gets filled (I do see that in other solutions though). This is how I read the if statement within the for loop:

“If the i’th number within sieve is not there, push this number to primes”

But… ‘sieve’ is empty the way I regard it?

…and then there is a for loop that quickly follows that I really don’t understand… :frowning:

Thanks!!!

1 Like

This may help: https://stackoverflow.com/questions/17265218/can-you-explain-this-method-of-finding-prime-numbers-in-javascript. Do read both responses. :slight_smile: