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