Implement log(n) exponentiation.