What Is Modular Arithmetic?
Learn what modular arithmetic is, how to perform it, and how it’s used in the real world.
Jason Marshall, PhD
Listen
What Is Modular Arithmetic?
Modular arithmetic is one of those things in math that sounds like it should be really hard but actually isn’t too tough once you know what it is. In fact, I guarantee that modular arithmetic is something that you use every single day. Don’t believe me? Well, keep on reading because today we’re talking about what modular arithmetic is, how to do it, and where it shows up in the real world.
What Is Cyclical Arithmetic?
If you can tell time, then you can perform modular arithmetic. Time keeps going on and on (possibly forever), but as you’ve probably noticed, clocks don’t have an infinite number of numbers on them. On a normal 12hour clock, the time goes from 1 to 2, then 2 to 3, then 3 to 4, and so on, up until it goes from 11 to 12, and then from 12 back to 1 again. In other words, we use a system with only 12 numbers for keeping track of hours of time. After the clock’s hand swings around those 12 hours, it starts over at 1 again.
And it’s not just the numbering of the hours that goes in a cycle, the numbering of the minutes in an hour and the seconds in a minute are cyclical too—both of these count from 1 up to 60 and then come back to 1 again. Want more examples? Well, the numbering of the days in a week goes from 1 to 7 and then back to 1 again. The numbering of days in a year goes from 1 to 365 (except in a leap year) and then back to 1 again. And the utility of this type of cyclical arithmetic isn’t just confined to keeping track of time—it has many other uses too.
What Is Modular Arithmetic?
But what does all this have to do with math? Well, it turns out that each example of cyclical counting that we’ve talked about so far can be described in terms of a type of math called modular arithmetic. Here’s the gist: You can think of modular arithmetic as a system of arithmetic for integers where the number line isn’t an infinitely long and straight line (as we’ve talked about in past discussions of integers), but is instead a line that curves around into a circle. In other words, modular arithmetic is a method for doing addition, subtraction, multiplication, and division with integers where the numbers curve around the number line cyclically instead of continuing on forever.
The length of the circular number line in modular arithmetic is called the modulus. For example, what’s the modulus when we tell time with a 12 hour clock? Well, for the hours, the modulus is 12 since there are 12 different numbers that the hour hand swings through before starting over again. And for the minutes and seconds, the modulus is 60 since there are 60 numbers that each of those hands swing through.
How to Perform Modular Addition
So that’s the idea of modular arithmetic. Now let’s talk about how to actually do it. It’s helpful here to keep the idea of a clock in mind. For arithmetic with a modulus of 12—also called arithmetic modulo 12—you can think of an actual clock that has 12 numbers on what is essentially a circular number line. For example, what’s 9 + 1 modulo 12? Well, if we think of starting at 9 on a normal 12hour clock and then moving forward 1 hour, we find that 9 + 1 modulo 12 is just 10. In this case, since 10 is less than the modulus of 12, the answer is the same as with normal math.
But what about something like 9 + 5 modulo 12? Here, in normal nonmodular arithmetic, the answer is 9 + 5 = 14. But in modular arithmetic with a modulus of 12, the numbers wrap around after we count up to 12. So to find 9 + 5 modulo 12, we need to count forward 5 hours from 9, being sure to start over once we get to 12. And when we do that we find that 9 + 5 modulo 12 is 2. In other words, using a clock to help visualize this, we start at 9 and then count forward 5 hours: 10, 11, 12, 1, and finally 2.
More Modulo Arithmetic
What if instead of modulo 12 arithmetic we want to perform modulo 5 arithmetic? For example, what’s 9 + 1 modulo 5? Well, this time you need to imagine a clock that cycles through only 5 numbers—from 0 at the top, then 1, 2, 3, and finally 4, before starting back at 0 again. (By the way, a normal 12hour clock could just as easily start with 0 at the top instead of 12—we just don’t traditionally do it that way.) To find 9 + 1 modulo 5, we need to start at the top of this new 5 numbered clock, count forward 9 spaces, and then count forward another 1 space. Where do you end up? Well, you end up right back where you started at the top. In other words, 9 + 1 modulo 5 is 0.
[[AdMiddle]So as not to get things confused with normal (meaning nonmodular) arithmetic, in modular arithmetic we don’t usually say that 9 + 1 modulo 5 is “equal” to 0. Instead we say that 9 + 1 modulo 5 is “congruent” to 0. And we write this as (9 + 1) (mod 5) ≡ 0. The word congruent here roughly means “the same as,” and we represent this idea of congruence in writing using a symbol that looks like an equals sign but with one extra horizontal line in the middle of it.
Modular Arithmetic in the Real World
Okay, that’s enough for now to get us started on our way towards understanding the insandouts of this new kind of admittedly strange arithmetic. We’ll return to this topic now and again in future articles to talk about other aspects of modular arithmetic and the other ways in which it’s used in the real world. That’s right, this isn’t all just random math stuff—it actually turns out to be very useful math stuff. But we’ll talk about exactly how it’s useful in later articles.
Practice Problems
Before we finish for today, here are a few practice problems for you to think about and use to check your understanding of what we’ve talked about so far:

What’s the modulus in the arithmetic that describes the numbering of the days of the week?

What’s the standard modulo 4 representation of the number 7? In other words, what’s 7 (mod 4)? Hint: It should be either 0, 1, 2, or 3.

What’s (7 + 8) (mod 9)?
You can find the answers to these questions at the very end of the article. After checking your answers, feel free to leave a comment at the bottom of the page and let me know how you did.
Wrap Up
If you have questions about how to solve these practice problems or any other math questions, please email them to me at mathdude@quickanddirtytips.com, send them via Twitter, or become a fan of the Math Dude on Facebook and get help from me and the other math fans there.
Until next time, this is Jason Marshall with The Math Dude’s Quick and Dirty Tips to Make Math Easier. Thanks for reading math fans!
Practice Problem Answers

Since there are 7 days in a week, the days of the week can be represented using 7 numbers. In other words, Sunday = 1, Monday = 2, Tuesday = 3, Wednesday = 4, Thursday = 5, Friday = 6, and Saturday = 7 (you can start with 1 on any day you choose…I’ve gone with what most calendars use). Since the days of the week are numbered from 1 to 7, the arithmetic that describes the numbering of the days of the week has a modulus of 7.

If we imagine a clock with a modulus of 4 that has only 4 positions (0 at the top, 1 on the right, 2 at the bottom, and 3 on the left), then we can find 7 (mod 4) by starting at 0 and counting forward 7 spaces: 1, 2, 3, 0, 1, 2…3. So 7 (mod 4) ≡ 3.

Think of a clock with a modulus of 9 that goes from 0 to 8. Starting at 7 and then counting forward (clockwise) 8 spaces, we end up at 6. So (7 + 8) (mod 9) ≡ 6.
Clock image from Shutterstock