(f, n, p, K)
return h
Compute ``f**n`` in ``GF(p)[x]`` using repeated squaring.

    Examples
    ========

    >>> from sympy.polys.domains import ZZ
    >>> from sympy.polys.galoistools import gf_pow

    >>> gf_pow([3, 2, 4], 3, 5, ZZ)
    [2, 4, 4, 2, 2, 1, 4]
Compute ``f**n`` in ``GF(p)[x]`` using repeated squaring.
Compute f ** n in GF ( p ) [ x ] using repeated squaring .
def gf_pow(f, n, p, K):
    """
    Compute ``f**n`` in ``GF(p)[x]`` using repeated squaring.

    Examples
    ========

    >>> from sympy.polys.domains import ZZ
    >>> from sympy.polys.galoistools import gf_pow

    >>> gf_pow([3, 2, 4], 3, 5, ZZ)
    [2, 4, 4, 2, 2, 1, 4]

    """
    if not n:
        return [K.one]
    elif n == 1:
        return f
    elif n == 2:
        return gf_sqr(f, p, K)

    h = [K.one]

    while True:
        if n & 1:
            h = gf_mul(h, f, p, K)
            n -= 1

        n >>= 1

        if not n:
            break

        f = gf_sqr(f, p, K)

    return h
def gf_pow ( f , n , p , K ) : if not n : return [ K . one ] elif n == 1 : return f elif n == 2 : return gf_sqr ( f , p , K ) h = [ K . one ] while True : if n & 1 : h = gf_mul ( h , f , p , K ) n -= 1 n >>= 1 if not n : break f = gf_sqr ( f , p , K ) return h