Java tutorial
//package com.java2s; import java.util.Arrays; public class Main { public static boolean[] is_prime_up_to_with_sieve(int num) { boolean[] prime = new boolean[num + 1]; Arrays.fill(prime, true); prime[0] = false; prime[1] = false; int num_sqrt = (int) Math.ceil(Math.sqrt(num)); for (int i = 2; i <= num_sqrt; i++) { if (prime[i]) for (int j = i * i; j <= num; j += i) prime[j] = false; } return prime; } }