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)

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 )
compute greatest factorial factorization of f in k[x] .