@@ -0,0 +1,565 @@
+import java.util.Arrays;%0A%0Apublic class Sieve %7B%0A%0A%09public static void main(String%5B%5D args) %7B%0A%09%09final int n = 1_000_000;%0A%0A%09%09// initially assume all integers are prime%0A%09%09boolean%5B%5D prime = new boolean%5Bn + 1%5D;%0A%09%09Arrays.fill(prime, true);%0A%09%09prime%5B0%5D = false;%0A%09%09prime%5B1%5D = false;%0A%0A%09%09// mark non-primes %3C= n using Sieve of Eratosthenes%0A%09%09for (int i = 2; i * i %3C= n; i++) %7B%0A%09%09%09// if i is prime, then mark multiples of i as nonprime%0A%09%09%09// suffices to consider mutiples i, i+1, ..., n/i%0A%09%09%09if (prime%5Bi%5D)%0A%09%09%09%09for (int j = i; i * j %3C= n; j++)%0A%09%09%09%09%09prime%5Bi * j%5D = false;%0A%09%09%7D%0A%09%7D%0A%0A%7D%0A

Create Sieve.java