```
def isEven(self, n):
return n % 2 == 0
def myPow(self, x, n):
# base case
if not n:
return 1
# n is negtive
if n < 0:
return 1.0 / self.myPow(x, -n)
# n is even
if self.isEven(n):
result = self.myPow(x, n / 2)
return result * result
else: # n is odd
return x * self.myPow(x, n-1)
```