cheetcode

141. Pow(x, n)Medium

Compute x raised to the power n.

Implement pow(x, n), which calculates x raised to the power n.

Handle negative exponents and return the computed numeric result.

Examples

Input: x = 2.0, n = 10
Output: 1024.0
Input: x = 2.0, n = -2
Output: 0.25
Input: x = -2.0, n = 3
Output: -8.0

Constraints

  • -100.0 < x < 100.0
  • -2^31 <= n <= 2^31 - 1
  • Either x is not zero or n > 0.