public static void prime_sieve(int n) {
        boolean[] prime = new boolean[n];
        prime[0] = false;
        prime[1] = false;
        int i;
        for (i = 2; i <= n; i++)
            prime[i] = true;

        double limit = Math.sqrt(n);
        for (i = 2; i <= limit; i++) {
            if (prime[i]) {
                for (int j = i * i; j <= n; j += i)
                    prime[j] = false;
            }
        }
    }