def power(x,n):
    """
    Compute x^n, where x, n can both be negative integer.
    :param x: Int -- the base
    :param n: Int -- the exponent

    :return: Int -- x^n
    """
    try:
        if n==0:
            return 1
        elif n==1:
            return x
        elif n>1:
            return x*power(x,n-1)
        elif n<0:
            m=-n
            return 1/(x*power(x,m-1))
            

    except ZeroDivisionError:
        return "Zero division error!"