- solve-chinese as nsprocedure
- as
- (list-of integer)
- ns
- (list-of integer)
Given a length-k list of integers as and a length-k list of coprime moduli ns, (solve-chinese as ns) returns the least natural number x that is a solution to the equations
x = a₁ (mod n₁) ... x = aₖ (mod nₖ)
The solution x is less than (* n1 ... nk).
The moduli ns must all be positive.
What is the least number x that when divided by 3 leaves a remainder of 2, when divided by 5 leaves a remainder of 3, and when divided by 7 leaves a remainder of 2?
> (solve-chinese '(2 3 2) '(3 5 7)) 23
Wikipedia: Chinese Remainder Theorem