Yes, this is your main implementation of the Eratosthenes sieve. There are several ways you can improve it, but first let go of the basic principle.
What you are doing is creating an array of booleans. The INDEX in the array represents the number we are testing to see if it is prime or not.
, , . -, " , 1 ".
for ( int i = 2; i < maxLimit; i++ )
INDEX 2 ( 3), 1 2 . ( , 1 ).
if ( sieve[i] == true ) continue;
, .
numberOfPrimes++;
if ( numberOfPrimes == 10001 ) {
number = i;
break;
}
INDEX, , , , , . , , , , 10001 , . , , .
for ( int j = i+i; j < maxLimit; j += i )
sieve[j] = true;
. , , 1. , , , . , for, 3. [2] ( ), ( 3 IS PRIME!). 3 . 3 . : [5] = true; [8] = true... .
, , , , , , , , . , , false, .
, , . , !