This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Chinese remainder theorem for integers

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.


numlib::ichrem(a, m)


numlib::ichrem(a,m) returns the least nonnegative integer x such that for i = 1, …, nops(m) if such a number exists; otherwise numlib::ichrem(a,m) returns FAIL.

The entries in m need not be pairwise coprime.

numlib::ichrem(a,m) returns an error if a is not a list of integers or m is not a list of natural numbers or a and m are not lists of the same length.


Example 1

Here the moduli are pairwise coprime. In this case, a solution always exists:


Example 2

Here the moduli are not pairwise coprime, and a solution does not exist:


Example 3

Also here the moduli are not pairwise coprime, but a solution nevertheless exists:




A list of integers


A list of natural numbers of the same length as a

Return Values

Either a nonnegative integer or FAIL.

See Also

MuPAD Functions

Was this topic helpful?