Function to build sieve
function buildSieve ( ) { for ( let i = 0 ; i < sieve . length ; i ++ ) { sieve [ i ] = true ; } sieve [ 0 ] = false ; sieve [ 1 ] = false ; for ( let p = 2 ; p * p <= 1000000 ; p ++ ) {