Given two integers
k
and
n
, write a function to compute
k
^
n
.
Problem Note
-
You can assume that
k
andn
are small and overflow doesn’t happen. -
Also, the value of
n
is >= 0
Example 1
Input: k = 4, n = 2
Output: 16
Explanation: 4^2 = 4*4 = 16
Example 2
Input: k = -7, n = 3
Output: -343
Explanation: (-7)^3 = (-7)*(-7)*(-7) = -343
Example 3
Input: k = 1, n = 4
Output: 1
Explanation: The power of 1 to any number is 1 itself. Here, 1^4 = 1*1*1*1 = 1
Example 4
Input: k = 4, n = 0
Output: 1
Explanation: The power of any number to 0 is 1. Here, 4^0 = 1