Sieve of Eratosthenes
function sieve ( ) { primes . fill ( true ) primes [ 0 ] = primes [ 1 ] = 0 ; for ( let i = 2 ; i * i <= maxn ; i ++ ) { if ( primes [ i ] ) { for ( let j = i * i ; j <= maxn ; j += i ) primes [ j ] = false ; } } }