Appearance
Pow(x,n) — LeetCode
Implement pow(x, n), which raises x to the integer power n, in logarithmic time.
pow(x, n)
x
n
x^n = x^(n/2) * x^(n/2) * x^(n%2) Recursively do power of n/2 and n%2. Multiply them together and pass back up.
x^n = x^(n/2) * x^(n/2) * x^(n%2)