/***
 * Implement pow(x, n).
 * Ignore case when x < 0, n % 2 euqls 0, and n < 0;
 */
public class PowXN{

    public double pow(double x, int n) {
        if (n == 0)
            return 1.0;
///*
        //binary power
        double half = pow(x, n/2);
        if(n % 2 == 0){
            return half * half;
        }else if (n > 0){
            return half * half * x;
        }else{
            return half * half / x;
        }
//*/
    }
    public static void main(String[] args){
        PowXN powxn = new PowXN();

        System.out.format("5e0 is: %f\n", powxn.pow(5, 0));
        System.out.format("3e-1 is: %f\n", powxn.pow(3, -1));
        System.out.format("2e4 is: %f\n", powxn.pow(2, 4));
    }

}

@@ -26,61 +26,8 @@
 n).%0A
- * Ignore case when x %3C 0, n %25 2 euqls 0, and n %3C 0;%0A
  */%0A
@@ -493,17 +493,17 @@
 ormat(%225
-e
+%5E
 0 is: %25f
@@ -553,17 +553,17 @@
 ormat(%223
-e
+%5E
 -1 is: %25
@@ -618,11 +618,12 @@
 at(%22
-2e4
+-2%5E3
  is:
@@ -644,12 +644,13 @@
 pow(
+-
 2, 
-4
+3
 ));%0A

modify PowXN.java