Created
September 9, 2014 04:44
-
-
Save sopherwang/b07e4785c5be091677a0 to your computer and use it in GitHub Desktop.
Revisions
-
sopherwang created this gist
Sep 9, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ public double pow(double x, int n) { if (n == 0) { return 1; } if (n < 0) { return 1.0 / power(x, -n); } else { return power(x, n); } } private double power(double x, int n) { if (n == 0) { return 1; } double tem = power(x, n / 2); if (n % 2 == 0) { return tem * tem; } else { return tem * tem * x; } }