if absn >= 4and absn % 2 == 0: half = int(n / 2) return self.myPow(x, half) * self.myPow(x, half) elif absn >= 4: half = int(n / 2) ret = self.myPow(x, half) * self.myPow(x, half) return ret * x if n > 0else ret / x elif n > 0: while n > 0: ret = ret * x n = n - 1 elif n < 0: while n < 0: ret = ret / x n = n + 1