Create a bool array " isPrime [ 0 . . N ] " and initialize all entries it as true . A value in isPrime [ i ] will finally be false if i is not a prime , else true .
bool [ ] isPrime = new bool [ Large + 1 ] ; for ( int p = 0 ; p <= Large ; p ++ ) isPrime [ p ] = true ; for ( int p = 2 ; p * p <= Large ; p ++ ) {