Sieve of Eratosthenes function to find all prime numbers
function sieve ( ) { for ( let i = 0 ; i < prime . length ; i ++ ) { prime [ i ] = true ; } prime [ 1 ] = false ; prime [ 0 ] = false ; for ( let i = 2 ; i < N ; i ++ ) { if ( prime [ i ] ) { for ( let j = i * 2 ; j < N ; j += i ) { prime [ j ] = false ; } } } }