public class Solution {
double a = 1 / base;
int b = exponent * -1;
return a * Power(a,b - 1);
}
if(exponent == 0){
return 1.0;
}
return base * Power(base,exponent - 1);
}
}
public double Power(double base, int exponent) {
//负次幂时
if(exponent < 0){double a = 1 / base;
int b = exponent * -1;
return a * Power(a,b - 1);
}
if(exponent == 0){
return 1.0;
}
return base * Power(base,exponent - 1);
}
}