chrem takes as argument 2 lists of integers of the same size.
chrem returns a list of 2 integers.
For example, chrem([a,b,c],[p,q,r]) returns the list
[x,lcm(p,q,r)] where
x=a mod p and x=b mod q and x=c mod r.
A solution x always exists if p, q, r
are mutually primes, and all the solutions are equal modulo p*q*r.
Be careful with the order of the parameters, indeed :
chrem([a,b],[p,q])=ichrem([a,p],[b,q])=
ichinrem([a,p],[b,q])
Examples :
Solve :
|
Input :
Output :
so, x=-17 (mod 65)
Solve :
|
Input :
Output :
so x=28 (mod 90)
Remark
chrem may be used to find the coefficients of a polynomial whose
equivalence classes are known modulo several integers, for example find
ax+b modulo 315=5 × 7 × 9 under the assumptions:
| , |
|
Input :
Output :
hence, a=-17 (mod 315) and b=156 (mod 315).