ôô

How to Do Multiplication and Division in Modular Arithmetic

Learn more about performing modular arithmetic, how it’s related to finding remainders in division, and how it can help you predict the future.

By
Jason Marshall, PhD,
Episode #054

How Subtraction Works in Modular Arithmetic

Up first: subtraction. This one is pretty easy, actually…so long as you have a good understanding of how to think about doing modular addition. And that’s because—just as with normal non-modular arithmetic—modular subtraction is basically the opposite of modular addition. Whereas you can think of modular addition as counting forward in the clockwise direction around the face of a “clock,” you can think of modular subtraction as counting backward around that “clock.”

For example, what’s (2 – 4) (mod 12)? Well, all you have to do is think about starting at 2 on a normal 12-hour clock, and then counting backwards 4 numbers: from 2 to 1, then to 12, 11, and finally 10. So (2 – 4) (mod 12) ≡ 10. Remember, the “≡” symbol here means these things are “congruent”—which is a word we use so we don’t get confused with the idea of “equality” in normal arithmetic.

Okay, how about arithmetic modulo 5: What’s (2 – 4) (mod 5)? Well, in this case, you need to think of a clock that has a zero at the top and then a 1, 2, 3, and 4 going around it in a clockwise direction. So, starting at 2 on this clock and working backwards 4 spaces—1, 0, 4, 3—we find that (2 – 4) (mod 5) ≡ 3.

How Multiplication and Division Work in Modular Arithmetic

Now that we can do both addition and subtraction, we just need to figure out how multiplication and division work in modular arithmetic. All you need to do is first figure out the answer to your multiplication or division problem using normal non-modular arithmetic, and then convert that number into its modular form. In other words, to find the answer to (3 x 7) (mod 12), first figure out what 3 x 7 is in regular arithmetic—it’s 21. Next, figure out what 21 is congruent to in math modulo 12. You can find the answer by starting at 0 on a normal 12-hour clock and then counting clockwise 21 spaces. Eventually, you’ll arrive at 9. That’s all there is to it! And division works the same way.

Pages

The Quick and Dirty Tips Privacy Notice has been updated to explain how we use cookies, which you accept by continuing to use this website. To withdraw your consent, see Your Choices.