Documentation Center

  • Trial Software
  • Product Updates

numlib::ichrem

Chinese remainder theorem for integers

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

numlib::ichrem(a, m)

Description

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.

Examples

Example 1

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

numlib::ichrem([2,3,2],[3,5,7])

Example 2

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

numlib::ichrem([5,6,8],[20,21,22])

Example 3

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

numlib::ichrem([5,6,7],[20,21,22])

Parameters

a

A list of integers

m

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?