base and an integer exponent. Return base raised to the power exponent. The exponent may be negative, in which case the result is one divided by base to the power |exponent|.
Do not use built-in exponentiation. The exponent can be around two billion, so multiplying |exponent| times will be too slow.
Answers within a relative error of 10⁻⁵ are accepted.base=3.0, exponent=4 → 81.0
3 · 3 · 3 · 3 = 81.
base=-2.0, exponent=-3 → -0.125
(−2)⁻³ = 1 / (−2)³ = 1 / (−8) = −0.125.
base=0.5, exponent=-2 → 4.0
base < 100exponent ≤ 2³¹ − 1base = 0, then exponent > 0base^exponent ≤ 10⁴base=3.0, exponent=4
81.0
Run checks the first 3 tests in your browser. Submit checks all 66 tests on the server, hidden ones included.