public static double pow (double x, int n) {//pass
        if (n == 0) return 1;
        else if (n == 1) return x;
        else if (n == -1) return 1/x;
        else {
            double temp = pow(x, Math.abs(n/2));
            if (n < 0) {
                if (n % 2 == 0) return 1 / (temp * temp);
                else return 1 / (x * temp * temp);
            }
            else {
                if (n % 2 == 0) return temp * temp;
                else return x * temp * temp;
            }
        }
    }