Function to build sieve
static void buildSieve ( ) { for ( int j = 0 ; j < sieve . Length ; j ++ ) sieve [ j ] = true ; sieve [ 0 ] = false ; sieve [ 1 ] = false ; for ( int p = 2 ; p * p <= 1000000 ; p ++ ) {