We have made array till 2 * n + 1 so that we can check prime number till that and conclude about sophie german prime .
bool [ ] prime = new bool [ 2 * n + 1 ] ; for ( int i = 0 ; i < prime . Length ; i ++ ) { prime [ i ] = true ; } sieve ( 2 * n + 1 , prime ) ; for ( int i = 2 ; i < n ; ++ i ) {