Pow(x, n) — Fast Exponentiation
Medium · Math & Number Theory · about 15 minutes
Asked at Meta, Google, LinkedIn, Bloomberg.
Implement myPow(x, n), which computes x raised to the integer power n (n may be negative, as low as −2³¹). Answers within 1e-5 relative error are accepted.