Loop till sqrt ( N ) to find prime numbers and make their multiple false in the bool array Prime
for ( int i = 2 ; i * i <= N ; i ++ ) { if ( Prime [ i ] ) { for ( int j = i * i ; j < N ; j += i ) { Prime [ j ] = false ; } } } }