O(ln N) solution to calculate Nth power of a number.