Multiplicative order: Difference between revisions

→‎{{header|Python}}: clarify and simplify code
(→‎{{header|Python}}: clarify and simplify code)
Line 120:
def isPrime(p):
return (p > 1) and all(f == p for f,e in factored(p):)
if f[0] <= p: break #always true
return f[0]==p
 
primeList = [2,3,5,7]
Line 129 ⟶ 127:
yield p
while 1:
p += 2
while not isPrime(p):
p += 2
primeList.append(p)
yield p
Line 138 ⟶ 136:
for p in primes():
j = 0
while a%p == 0:
a /= p
j += 1
if j > 0:
yield (p,j)
if a < p*p: break
Line 148 ⟶ 146:
 
def multOrdr1(a,(qp,e) ):
m = qp**e
t = (qp-1)*(qp**(e-1)) # = Phi(qp**e) where qp prime
qs = [1,]
for f in factored(t):
Anonymous user