Time for an 2014 update…

This commit is contained in:
Ingy döt Net 2014-01-17 05:32:22 +00:00
parent 372c577f83
commit 09687c4926
2520 changed files with 34227 additions and 7318 deletions

View file

@ -0,0 +1,23 @@
function factors(n)
f = [one(n)]
for (p,e) in factor(n)
f = reduce(vcat, f, [f*p^j for j in 1:e])
end
return length(f) == 1 ? [one(n), n] : sort!(f)
end
function multorder(a, m)
gcd(a,m) == 1 || error("$a and $m are not coprime")
res = one(m)
for (p,e) in factor(m)
m = p^e
t = div(m, p) * (p-1)
for f in factors(t)
if powermod(a, f, m) == 1
res = lcm(res, f)
break
end
end
end
res
end