Chinese remainder theorem: Difference between revisions

Line 975:
This example solves an extended version of the Chinese Remainder theorem by allowing an optional third parameter <CODE>d</CODE> which defaults to 0 and is an integer. The solution returned is the smallest solution &gt;= d. (This optional parameter is common in many/most real-world applications of the Chinese Remainder Theorem.)
 
This program also works with arbitrarily-large integers and peforms efficiently due to Frink's built-in <CODE>modInverse</CODE> function.
 
Input is validated and useful error messages are emitted if the input data is invalid. If a solution cannot be found, this returns the special value <CODE>undef</CODE>.
494

edits