소수를 구하는 또다른 방법입니다.
러닝타임은 N + N/2 + N/3 + N/5 + N/7 + N/11 + ....
class Primes {
    public static void main(String[] args) { 
        int num = 100;
        if (args.length > 0)
            num = Integer.parseInt(args[0]);
        getPrime(num);
    }
    public static void getPrime(int max) {
        boolean[] a = new boolean[max];
        for (int i = 2; i < max; i++) 
            a[i] = true;
        int to = (int)Math.sqrt(max);
        for (int i = 2; i < to; i++)
            if (a[i] != false)
        for (int j = i; j*i < max; j++) 
            a[i*j] = false;
        for (int i = 2; i < max; i++)
            if (a[i]) 
                System.out.print(" " + i);
        System.out.println();
    }
}
[출처] http://blog.naver.com/charityno3?Redirect=Log&logNo=80006915007