@@ -0,0 +1,1630 @@
+package net.biz.algorithm.prime;%0A%0A/**%0A * %3Cp/%3E%0A * User : krisibm@163.com%0A * Date: 2015/3/27%0A * Time: 0:51%0A */%0Apublic class PrimeNumber %7B%0A%0A    /**%0A     * The default stopping point for primes%0A     */%0A    public static final long DEFAULT_STOP = 4294967295L;%0A    /**%0A     * The first prime number%0A     */%0A    public static final int FP = 2;%0A%0A    static int MAX = 100;%0A%0A    public static void main(String%5B%5D args) %7B%0A        long%5B%5D prime = new long%5BMAX%5D;%0A%0A        long stop = DEFAULT_STOP;%0A        stop = 100;%0A%0A        prime%5B1%5D = FP;       // P1 (ignore prime%5B0%5D)%0A        long n = FP + 1;       // odd candidates%0A        int j = 1;        // numberFound%0A%0A        boolean isPrime = true;  // for 3%0A%0A        do %7B%0A%0A            if (isPrime) %7B%0A                if (j == MAX - 1) %7B%0A                    // Grow array dynamically if needed%0A                    long%5B%5D np = new long%5BMAX * 2%5D;%0A                    System.arraycopy(prime, 0, np, 0, MAX);%0A                    MAX *= 2;%0A                    prime = np;%0A                %7D%0A                prime%5B++j%5D = n;  // P2%0A                isPrime = false;%0A            %7D%0A            n += 2;        // P4%0A%0A            for (int k = 2; k %3C= j && k %3C MAX; k++) %7B  // P5, P6, P8%0A                long q = n / prime%5Bk%5D;%0A                long r = n %25 prime%5Bk%5D;%0A                if (r == 0) %7B%0A                    break;%0A                %7D%0A                if (q %3C= prime%5Bk%5D) %7B    // P7%0A                    isPrime = true;%0A                    break;%0A                %7D%0A            %7D%0A%0A        %7D while (n %3C stop);        // P3%0A%0A        for (int i = 1; i %3C= j; i++)%0A            System.out.println(prime%5Bi%5D);%0A    %7D%0A%0A%0A%7D%0A

prime number