Chinese theorem

Returns the solution of the system of equations given by the Chinese theorem: let n subscript 1 comma... comma n subscript k be integers greater than 1, and let us denote by N the product of the n subscript i. The Chinese remainder theorem states that if the n subscript i are pairwise coprime, and if a subscript 1 comma... comma a subscript k are any integer, 0 less or equal than a subscript i less than n subscript i, then there exists an integer x such that

table row cell x identical to a subscript 1 space left parenthesis text mod end text space n subscript 1 right parenthesis end cell row vertical ellipsis row cell x identical to a subscript k space left parenthesis text mod end text space n subscript k right parenthesis end cell end table

and two such x are congruent modulo N.

chinese_theorem(Integer, Integer, Integer, Integer)

Given four integers a subscript 1, a subscript 2, n subscript 1, n subscript 2, returns x, the solution of the system of equations described above.

chinese_theorem(List, List)

Given two lists left curly bracket a subscript 1 comma... comma a subscript k right curly bracket and left curly bracket n subscript 1 comma... comma n subscript k right curly bracket, returns x, the solution of the system of equations described above.