- mod xprocedure
- x
- exact rational
Converts a rational number x to a natural number less than the current modulus.
If x is an integer, this is equivalent to (modulo x n). If x is a fraction, an integer input is generated by multiplying its numerator by its denominator’s modular inverse.
Examples:
> (with-modulus 7 (mod (* 218 7))) 0 > (with-modulus 7 (mod 3/2)) 5 > (with-modulus 7 (mod/ 3 2)) 5 > (with-modulus 7 (mod 3/7)) Error: (modular-inverse) bad argument type - not coprime to modulus 7: 7