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