class Primes{ public static void main(String[] args){ int N = Integer/parseInt(args[0]); boolean[] a = new boolean[N]; for (int i = 2; i<N; i++) a[i] = true; for (int i = 2; i<N; i++) if (a[i] != false) for (int j = i; j*i < N; j++) a[i*j] = false; for (int i = 2; i < N; i++) if (i > N - 100) // Зачем это проверять? if (a[i]) Out.print(" " + i); Out.println(); } } I do not understand why in the last cycle with the output of numbers to do the restriction if (i > N - 100) ?
PS program description, which is given in the textbook: This program is designed to print all prime numbers less than the integer specified by the argument on the command line. For this, an array of logical values is calculated, in which a[i] is true if i prime number, and false otherwise. First, all elements of the array are entered true to indicate that there are no known composite numbers yet. Then in the elements of the array, the indices of which are composite numbers, is entered false . If, after setting all the divisors of primes smaller than i to false , the element a[i] is still true , then its index is a prime number