Modular arithmetic: Difference between revisions

Content added Content deleted
Line 1,893: Line 1,893:


The program is for R7RS Scheme.
The program is for R7RS Scheme.

"Modular integers" are not introduced here as a type distinct from "integers". Instead, a modulus may be imposed on "enhanced" versions of arithmeti operations.

Note the use of <code>floor-remainder</code> instead of <code>truncate-remainder</code>. The latter would function incorrectly if there were negative numbers.


<syntaxhighlight lang="scheme">
<syntaxhighlight lang="scheme">