题解 | #幂#
幂
http://www.nowcoder.com/practice/8865ac17c9bd4adeb01e16b141fd197f
function _pow(number,power) {
// 补全代码
// 补全代码
// methods1 Math.pow()方法
return Math.pow(number, power); //method1
// methods2 遍历相乘
let x = 1;
for(let i = 1; i <= power; i++) {
x *= number;
}
return x;
// methods3 递归 x^0 == 1
return (power > 0) ? number * _pom(number, power -1) : 1/(number * _pom(number, power -1));
}