Mark all numbers which do not generate prime number by 2 * i + 1
for ( let i = 1 ; i <= Math . floor ( ( Math . sqrt ( MAX ) - 1 ) / 2 ) ; i ++ ) { for ( let j = ( i * ( i + 1 ) ) << 1 ; j <= Math . floor ( MAX / 2 ) ; j = j + 2 * i + 1 ) { marked [ j ] = true ; } }