def dmp_trial_division(f, factors, u, K):
 result = []
 for factor in factors:
  k = 0
  while True:
   (q, r) = dmp_div(f, factor, u, K)
   if dmp_zero_p(r, u):
    (f, k) = (q, (k + 1))
   else:
    break
  result.append((factor, k))
 return _sort_factors(result)

def dmp_trial_division ( f , factors , u , K ) : result = [ ] for factor in factors : k = 0 while True : ( q , r ) = dmp_div ( f , factor , u , K ) if dmp_zero_p ( r , u ) : ( f , k ) = ( q , ( k + 1 ) ) else : break result . append ( ( factor , k ) ) return _sort_factors ( result )
determine multiplicities of factors using trial division .