Problems178
Search for a command to run...
Initialization
Compute 2.0000 raised to the power 13 by repeated multiplication.
Brute Force
1function myPow(x, n) {2 if (n === 0 || x === 1.0) return 1;3 //x: 2n: 134 let temp = n;5 6 if (n < 0) {7 x = 1 / x;8 temp = -n;9 }10 11 let ans = 1;12 for (let i = 0; i < temp; i++) {13 ans *= x;14 }15 return ans;16}