protected static int getNPrime(int n) {
        if (n == 1) return FIRST_PRIME;
        if (n == 2) return SECOND_PRIME;

        int prime = SECOND_PRIME;
        int count = 2;
        for (int i : primesByOrder.keySet()) {
            if (n > i) {
                count = i;
                prime = primesByOrder.get(i);
            } else break;
        }

        while (count < n) {
            prime += ADVANCE;
            boolean isPrime = true;
            for (int i = FIRST_PRIME; i * i <= prime; i++) {
                if (prime % i == 0) {
                    isPrime = false;
                    break;
                }
            }
            if (isPrime) count++;
        }
        return prime;
    }