private boolean isPrime(int n) {
        if (n < 2) {
            return false;
        } else if (n == 2 || n == 3) {
            return true;
        } else if (n % 2 == 0 || n % 3 == 0) {
            return false;
        } else {
            double max_divisor = Math.sqrt(n);
            int divisor = 5;
            while (divisor <= max_divisor) {
                if (n % divisor == 0 || n % (divisor + 2) == 0) {
                    return false;
                }
                divisor += 6;
            }
            return true;
        }
    }