def gf_factor(f, p, K):
 (lc, f) = gf_monic(f, p, K)
 if (gf_degree(f) < 1):
  return (lc, [])
 factors = []
 for (g, n) in gf_sqf_list(f, p, K)[1]:
  for h in gf_factor_sqf(g, p, K)[1]:
   factors.append((h, n))
 return (lc, _sort_factors(factors))

def gf_factor ( f , p , K ) : ( lc , f ) = gf_monic ( f , p , K ) if ( gf_degree ( f ) < 1 ) : return ( lc , [ ] ) factors = [ ] for ( g , n ) in gf_sqf_list ( f , p , K ) [ 1 ] : for h in gf_factor_sqf ( g , p , K ) [ 1 ] : factors . append ( ( h , n ) ) return ( lc , _sort_factors ( factors ) )
factor polynomials in gf(p)[x] .