text: C # implementation of above approach
code: using System ; using System . Collections ; using System . Collections . Generic ; class GFG { static int MAX = 105 ; static 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 ; } } } class pair { public int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } }