sieve of Eratosthenes to compute the prime numbers
function sieve ( ) { let isPrime = new Array ( MAX ) ; for ( let i = 0 ; i < MAX ; i ++ ) isPrime [ i ] = true ; for ( let p = 2 ; p * p < MAX ; p ++ ) { if ( isPrime [ p ] == true ) { for ( let i = p * 2 ; i < MAX ; i += p ) isPrime [ i ] = false ; } }