public static TreeSet<Integer> primeSieve(int limit) {
        boolean[] numberList = new boolean[limit + 1];
        TreeSet<Integer> primeList = new TreeSet<>();

        for (int i = 2; i <= limit; i++) {
            numberList[i] = true;
        }

        for (int i = 2; i * i <= limit; i++) {
            if (numberList[i]) {
                for (int j = i; i * j <= limit; j++) {
                    numberList[i * j] = false;
                }
            }
        }

        for (int i = 2; i <= limit; i++) {
            if (numberList[i]) {
                primeList.add(i);
            }
        }

        return primeList;
    }