3 2 3 3 5 2 7
The value 23 satisfies all three equations: 23 mod 3 is 2, 23 mod 5 is 3, and 23 mod 7 is 2. No smaller non-negative value satisfies all three.
23
2 1 2 2 3
The value 5 is 1 modulo 2 and 2 modulo 3. The smaller non-negative values 0 through 4 fail at least one equation.
5
3 0 3 0 5 0 7
The value 0 satisfies all three equations because every required remainder is 0, so the smallest non-negative answer is 0.
0
Given nnn equations of the form: x≡ai(modmi)x \equiv a_i \pmod{m_i}x≡ai(modmi)
where all mim_imi are pairwise coprime (their GCD is 1), find the smallest non-negative integer xxx that satisfies all equations.