Skip to main content

chinese_remainder

Function chinese_remainder 

Source
pub fn chinese_remainder(
    residues: &[i128],
    moduli: &[i128],
) -> Result<(i128, i128), ErrorsJSL>
Expand description

Solves the simultaneous congruences x ≡ r_i (mod m_i) and returns (x, M) with 0 ≤ x < M, where M = lcm(m_i), so that the solution set is x + kM. The moduli need not be pairwise coprime (Garner-style pairwise merging with gcd); returns an error when the congruences are inconsistent or M overflows i128.