Problem of the day
You are given two numbers ’x’(it’s a float), and ’n’(it’s a integer).
Your task is to calculate ‘x’ raised to power ‘n’, and return it.
The expected time complexity is ’O(logn)’, and the expected space complexity is ’O(1)’, where ‘n’ is the power to which the number should be raised.
In the output, you will see the number returned by you upto 6 decimal places.
Input: ‘x’ = 10, ‘n’ = 4
Output: 10000.000000
Explanation: On raising ‘x’ to the power of ‘n’, the result is 10000.
<br>
The first line contains two numbers, ‘x’, and ‘n’, denoting the number to be raised and the power to which it should be raised.
Return the number as described above.
You don't need to print anything. Just implement the given function.
10 4
10000.000000
Input: ‘x’ = 10, ‘n’ = 4
Output: 10000.000000
Explanation: On raising ‘x’ to the power of ‘n’, the result is 10000.
<br>
3.7 3
50.653000
Input: ‘x’ = 3.7, ‘n’ = 3
Output: 50.653000
Explanation: On raising ‘x’ to the power of ‘n’, the result is 50.653.
-9 <= n <= 9
1 <= x <= 50
Time Limit: 1-sec