Power(x, n) Problem
Power(x, n) Problem — ExecCode Easy DSA Practice
Solve the Power(x, n) problem on ExecCode. Free online easy DSA practice in Recursion Basics. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Implement pow(x, n), which calculates x raised to the power n(i.e., x). x is a float, and n is an integer. Example: pow(2.0, 10) = 1024.0
Examples
Input x = 2.0, n = 3; Output 8.0. Input x = 2.0, n = -2; Output 0.25. Input x = 3.0, n = 5; Output 243.0
Constraints
-100.0 < x < 100.0 -2^31 <= n <= 2^31 - 1 n is an integer
Practice Power(x, n) free on ExecCode. Browse DSA problems, topic map, and placement guides.