Chinese theorem

Returns the solution of the system of equations given by the Chinese theorem: let n1,...,nk be integers greater than 1, and let us denote by N the product of the ni. The Chinese remainder theorem states that if the niLaTeXn_i are pairwise coprime, and if a1,...,ak are any integer, 0ai<ni, then there exists an integer x such that

xa1 (mod n1)xak (mod nk)

and two such xLaTeXx are congruent modulo NLaTeXN.

Syntax

chinese_theorem(Integer, Integer, Integer, Integer)
chinese_theorem(List, List)

Description

Given four integers a1, a2, n1, n2, returns xLaTeXx, the solution of the system of equations described above.

arithmetic.chinese_theorem1.calc.png

Given two lists {a1,...,ak} and {n1,...,nk}, returns xLaTeXx, the solution of the system of equations described above.

arithmetic.chinese_theorem2.calc.png