Code example for BitSet

Methods: get

0
    } 
  
    public boolean is_composite(int k)
    { 
        assert k >= 3 && (k % 2) == 1;
        return sieve.get((k-3)/2);
    } 
  
    public void set_composite(int k)
    { 
        assert k >= 3 && (k % 2) == 1;
        sieve.set((k-3)/2);
    } 
  
    public static List<Integer> sieve_of_eratosthenes(int max)
    { 
        Sieve sieve = new Sieve(max + 1); // +1 to include max itself
        for (int i = 3; i*i <= max; i += 2) {
            if (sieve.is_composite(i))
	             continue;