讨论/《图解算法数据结构》 - 剑指 Offer 16. 数值的整数次方/
《图解算法数据结构》 - 剑指 Offer 16. 数值的整数次方

var myPow = function(x, n) {

if(n==0)return 1;
let symbom = n > 0 ? true : false;
let remain = 1;
let result = x;
let newN = n > 0 ? n : -n;;
while(newN > 1){
    remain *= (newN%2 != 0 ? result : 1);
    result = result * result;
    newN = parseInt((newN-newN%2)/2);
    console.log(result,newN);
}
return symbom ? result * remain : 1/(result * remain);

};

1