Expand description
The Chinese remainder theorem.
See the book entry Divisibility and modular arithmetic.
Functions§
- chinese_
remainder - Solves the simultaneous congruences
x ≡ r_i (mod m_i)and returns(x, M)with0 ≤ x < M, whereM = lcm(m_i), so that the solution set isx + kM. The moduli need not be pairwise coprime (Garner-style pairwise merging withgcd); returns an error when the congruences are inconsistent orMoverflowsi128.