Sieve of Eratosthenes function to find all prime numbers
void sieve ( ) { memset ( prime , true , sizeof prime ) ; prime [ 1 ] = false ; prime [ 0 ] = false ; for ( int i = 2 ; i < N ; i ++ ) if ( prime [ i ] ) for ( int j = i * 2 ; j < N ; j += i ) prime [ j ] = false ; }