Jump to content

Chinese remainder theorem: Difference between revisions

fixed Julia example for larger numbers
(fixed Julia example for larger numbers)
Line 1,176:
<lang julia>function chineseremainder(n::Array, a::Array)
Π = prod(n)
mod(sum(ai * invmod(Π ÷ ni, ni) * (Π ÷ ni) for (ni, ai) in zip(n, a)), Π)
end
 
1

edit

Cookies help us deliver our services. By using our services, you agree to our use of cookies.