Skip to main content

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 nin_i are pairwise coprime, and if a1,...,ak are any integer, 0ai<ni, then there exists an integer x such that

xa1(modn1)xak(modnk)

and two such xx are congruent modulo NN.

Syntax

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

Description

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

arithmetic.chinese_theorem1.calc.png

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

arithmetic.chinese_theorem2.calc.png