Provide an algorithm in python to calculate the power of an integer.
def power_of_integer(x, n):
    if n == 0:
        return 1
    
    if n % 2 == 0:
        return power_of_integer(x*x, n//2)
    else:
        return x * power_of_integer(x*x, (n-1)//2)