(a, b, n)
return wre, wim
Complex integer power: computes (a+b*I)**n exactly for
    nonnegative n (a and b must be Python ints).
Complex integer power: computes (a+b*I)**n exactly for
    nonnegative n (a and b must be Python ints).
Complex integer power : computes ( a + b * I ) ** n exactly for nonnegative n ( a and b must be Python ints ) .
def complex_int_pow(a, b, n):
    """Complex integer power: computes (a+b*I)**n exactly for
    nonnegative n (a and b must be Python ints)."""
    wre = 1
    wim = 0
    while n:
        if n & 1:
            wre, wim = wre*a - wim*b, wim*a + wre*b
            n -= 1
        a, b = a*a - b*b, 2*a*b
        n //= 2
    return wre, wim
def complex_int_pow ( a , b , n ) : wre = 1 wim = 0 while n : if n & 1 : wre , wim = wre * a - wim * b , wim * a + wre * b n -= 1 a , b = a * a - b * b , 2 * a * b n //= 2 return wre , wim