Previous Page Next Page Contents

numlib::ichrem -- Chinese remainder theorem for integers

Introduction

numlib::ichrem(a,m) returns the least nonnegative integer x such that (x-a[i]) mod m[i]=0 for i=1,..,m if such a number exists; otherwise numlib::ichrem(a,m) returns FAIL.

Call(s)

numlib::ichrem(a, m)

Parameters

a - a list of integers
m - a list of natural numbers of the same length as a

Returns

either a nonnegative integer or FAIL.

Related Functions

numlib::lincongruence

Details

Example 1

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

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

Example 2

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

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

Example 3

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

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

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000