Exponent problem algo++

is it faster than pow()

Yes it is much faster than pow(). And also takes O(logn) time.