text: Javascript implementation of above approach
code: let MAX = 105 , q = 0 ; let prime = new Array ( MAX ) ; function sieve ( ) { for ( let i = 2 ; i * i < MAX ; i ++ ) { if ( prime [ i ] == 0 ) { for ( let j = i * i ; j < MAX ; j += i ) prime [ j ] = 1 ; } } }