# HG changeset patch
# User David Roe <roed@math.harvard.edu>
# Date 1285838316 14400
# Node ID 74423238ccd88ebd93604185c5d82d3d2cf285af
# Parent b65e732ec9dd94231437b8a9ce2bdce1117caa40
[mq]: 7931_fix2.patch
diff r b65e732ec9dd r 74423238ccd8 sage/rings/finite_rings/integer_mod.pyx
a

b


1027  1027  [1, 15, 13, 3, 9, 7, 5, 11] 
1028  1028  sage: (mod(22,31)^200).nth_root(200) 
1029  1029  5 
 1030  sage: mod(3,6).nth_root(0,all=True) 
 1031  [] 
 1032  sage: mod(3,6).nth_root(0) 
 1033  Traceback (most recent call last): 
 1034  ... 
 1035  ZeroDivisionError 
 1036  sage: mod(1,6).nth_root(0,all=True) 
 1037  [1, 2, 3, 4, 5] 
1030  1038  
1031  1039  TESTS:: 
1032  1040  
… 
… 

1054  1062  raise NotImplementedError 
1055  1063  K = self.parent() 
1056  1064  n = Integer(n) 
 1065  if n == 0: 
 1066  if self == 1: 
 1067  if all: return [K(a) for a in range(1,K.order())] 
 1068  else: return self 
 1069  else: 
 1070  if all: return [] 
 1071  else: raise ZeroDivisionError 
1057  1072  F = K.factored_order() 
1058  1073  if len(F) == 0: 
1059  1074  if all: 
… 
… 

1077  1092  p, k = F[0] 
1078  1093  if self.is_zero(): 
1079  1094  if n < 0: 
1080   raise ZeroDivisionError 
 1095  if all: return [] 
 1096  else: raise ZeroDivisionError 
1081  1097  if all: 
1082  1098  if k == 1: 
1083  1099  return [self] 