text: C ++ implementation of above approach
code: #include <bits/stdc++.h> NEW_LINE using namespace std ; #define MAX  105 NEW_LINE void sieve ( int prime [ ] ) { for ( int i = 2 ; i * i <= MAX ; i ++ ) { if ( prime [ i ] == 0 ) { for ( int j = i * i ; j <= MAX ; j += i ) prime [ j ] = 1 ; } } }