← Questions

Implement pow(x, n)

0
MetaCodingLast asked Apr 2026

Compute x raised to an integer power n (which may be negative) in O(log n) multiplications by squaring, rather than multiplying n times. Handle n = 0, negative exponents and overflow at the edge of the integer range.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding