@@ -0,0 +1,1619 @@
+package practice.mathematics;%0A%0Apublic class SieveOfEratosthenes %7B%0A%0A    private boolean%5B%5D sieve;%0A    private int maxNumber;%0A%0A    public SieveOfEratosthenes(int maxNumber) %7B%0A        this.maxNumber = maxNumber;%0A        sieve = new boolean%5BmaxNumber%5D;%0A        createSieve();%0A    %7D%0A%0A    private void createSieve() %7B%0A        sieve%5B2%5D = sieve%5B3%5D = sieve%5B5%5D = true;%0A%0A        int i;%0A        for (i = 1; i * 6 + 5 %3C sieve.length; i++) %7B%0A            sieve%5Bi * 6 + 1%5D = true;%0A            sieve%5Bi * 6 + 5%5D = true;%0A        %7D%0A        if (i * 6 + 1 %3C sieve.length) %7B%0A            sieve%5Bi * 6 + 1%5D = true;%0A        %7D%0A        %0A        for (i = 0; (i * 6 + 5) * (i * 6 + 5)  %3C sieve.length; i++) %7B%0A            filter(i * 6 + 1);%0A            filter(i * 6 + 5);%0A        %7D%0A        %0A        if ((i * 6 + 1) * (i * 6 + 1) %3C sieve.length) %7B%0A            filter(i * 6 + 1);%0A        %7D%0A%0A    %7D%0A%0A    private void filter(int i) %7B%0A        if (sieve%5Bi%5D) %7B%0A            for (int j = 2; j * i %3C sieve.length; j++) %7B%0A                sieve%5Bi * j%5D = false;%0A            %7D%0A        %7D%0A    %7D%0A%0A    public void printResult() %7B%0A        int count = 0;%0A        System.out.println(%22Prime numbers: %22);%0A        for (int i = 0; i %3C sieve.length; i++) %7B%0A            if (sieve%5Bi%5D) %7B%0A                System.out.print(String.format(%22%25d %22, i));%0A                count++;%0A                if (count %25 10 == 0) %7B%0A                    System.out.println(%22%22);%0A                %7D%0A            %7D%0A        %7D%0A        System.out.println(%22%22);%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        SieveOfEratosthenes soe = new SieveOfEratosthenes(5000);%0A        soe.printResult();%0A    %7D%0A%0A%7D%0A

Add SieveOfEratosthenes