-
Notifications
You must be signed in to change notification settings - Fork 7
Modulo arithmetic
Albert van der Horst edited this page Mar 2, 2022
·
3 revisions
After
WANT x^x
you can use the modular exponentation operation x^x
to
calculate a^b (modulo c) from ( a b c -- )
Also available then are
+m -m *m /m **m
operations. Those require the filling in of the global _m variable and are analogue to the integer operators without the suffix amd the operations are -- you guessed it -- performed modulo _m. The input numbers must be smaller than _m . A useful technique to reduce a number that is too large is by the phrase: 1 *m
_m
may be any positive number. However if it is not prime, modular division is not generally possible and /m
will give erroneous result. Division by zero, as always, is out of the question.
See also the NAQ about inlining.