public double myPow_iterate(double x, int n) {
        if (n == 0)
            return 1;
        double result = 1.0;
        if (n < 0) {
            n *= -1;
            x = 1 / x;
        }
        while (n > 0) {
            if (n % 2 == 0) {
                x *= x;
                n /= 2;
            } else {
                result *= x;
                n -= 1;
                n /= 2;
                x *= x;
            }
        }
        return result;
    }