MCPcopy Create free account
hub / github.com/codedecks-in/LeetCode-Solutions / myPow

Function myPow

JavaScript/50.Powxn.js:40–58  ·  view source on GitHub ↗
(x, n)

Source from the content-addressed store, hash-verified

38 * @return {number}
39 */
40var myPow = function(x, n) {
41 if (n < 0) {
42 x = 1 / x;
43 n = -n;
44 }
45 return pow(x, n);
46
47 function pow(x, n) {
48 if (n == 0) {
49 return 1.0;
50 }
51 const half = pow(x, parseInt(n / 2));
52 if (n % 2 === 0) {
53 return half * half;
54 } else {
55 return half * half * x;
56 }
57 }
58};

Callers

nothing calls this directly

Calls 1

powFunction · 0.85

Tested by

no test coverage detected