(f, K)
Compute greatest factorial factorization of ``f`` in ``K[x]``.

    Examples
    ========

    >>> from sympy.polys import ring, ZZ
    >>> R, x = ring("x", ZZ)

    >>> R.dup_gff_list(x**5 + 2*x**4 - x**3 - 2*x**2)
    [(x, 1), (x + 2, 4)]
Compute greatest factorial factorization of ``f`` in ``K[x]``.
Compute greatest factorial factorization of f in K [ x ] .
def dup_gff_list(f, K):
    """
    Compute greatest factorial factorization of ``f`` in ``K[x]``.

    Examples
    ========

    >>> from sympy.polys import ring, ZZ
    >>> R, x = ring("x", ZZ)

    >>> R.dup_gff_list(x**5 + 2*x**4 - x**3 - 2*x**2)
    [(x, 1), (x + 2, 4)]

    """
    if not f:
        raise ValueError("greatest factorial factorization doesn't exist for a zero polynomial")

    f = dup_monic(f, K)

    if not dup_degree(f):
        return []
    else:
        g = dup_gcd(f, dup_shift(f, K.one, K), K)
        H = dup_gff_list(g, K)

        for i, (h, k) in enumerate(H):
            g = dup_mul(g, dup_shift(h, -K(k), K), K)
            H[i] = (h, k + 1)

        f = dup_quo(f, g, K)

        if not dup_degree(f):
            return H
        else:
            return [(f, 1)] + H
def dup_gff_list ( f , K ) : if not f : raise ValueError ( "greatest factorial factorization doesn't exist for a zero polynomial" ) f = dup_monic ( f , K ) if not dup_degree ( f ) : return [ ] else : g = dup_gcd ( f , dup_shift ( f , K . one , K ) , K ) H = dup_gff_list ( g , K ) for i , ( h , k ) in enumerate ( H ) : g = dup_mul ( g , dup_shift ( h , - K ( k ) , K ) , K ) H [ i ] = ( h , k + 1 ) f = dup_quo ( f , g , K ) if not dup_degree ( f ) : return H else : return [ ( f , 1 ) ] + H