Okay, I give up. How does using the square root of the number being checked apply to the Sieve of Erastothenes algorithm???
Look at my code in post #19.
To do the prime.push(chk), we must loop all the way to the max num we are wanting to check.
And then the inner loop must also go all the way to that same max num to be sure all the multiples of the given prime are marked.
But notice that the marking loop at least only starts at the found prime number, so it's not terrible. But we could get 4 times as efficient by only considering odd numbers and by not bother with marking even multiples of a prime number. Oh, and we don't need to mark the prime number we just found.
Further than that...I dunno. What do you think can be done? And how does square root apply to this algorithm??
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.