Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1%
- * Recursive method for raising x to the power n.
- “gpren >0
- “ Gpre for n =0, x 1= 0
- * Gparan x The nusber being raised to 3 power.
- “ Gparan n The exponent.
- “ Greturn x raised to the power n.
- */
- public static double power(double x, int n) {
- if (<o)
- return 1/ (x * power(x, -n));
- } else if (n == 0) {
- return 1;
- ¥ etse 4l
- return x * pover(x, n - 1);
- 3
Advertisement
Add Comment
Please, Sign In to add comment