Modular arithmetic gives us a very simple and straightforward—but also non-trivial—example of a group, and since we’ve only covered it explicitly in the solutions to lesson 22, we should devote a little time to it here.
Let’s begin with an example. Consider the set , which has 6 integers in it. We can then define addition modulo 6 as follows. Take any two elements in this set and add them together normally. If their sum is less than 6, leave it alone (so that, for example, like usual), and if their sum is greater than or equal to 6, subtract 6 from it and then leave it alone (so that, for example, and we say that “five plus three equals two modulo six”). Some more examples of addition in this somewhat whacky group would be , and , all modulo 6.
One practical example of this kind of group is the type of addition we do whenever we tell time. Namely, telling time is nothing but doing addition modulo 12 or 24, depending on the country in which you’re reading this. For example, if you’re in an am-pm country and it’s 11 o’clock right now, and someone asks to meet you in 2 hours, you know that you need to check your schedule for 1 o’clock and not for 13 o’clock (since in an am-pm country the latter does not exist). Similarly, addition modulo 6 or 14 or 75 is nothing but “cycling around a clock” with 6 or 14 or 75 hours on it, respectively. This realization lets us define modular arithmetic more generally.
Definition: Let be the set (so that, for example, and ). Then addition modulo N is the addition within this set such that a) if the sum of any two numbers in the set is less than we leave the sum unchanged and b) if the sum of any two numbers is greater than or equal to we subtract from the sum and then leave it unchanged.\\
The first and most important thing we’ll note about this definition is that addition modulo always turns into a group with the abstract group product being, of course, addition modulo and with the identity being . Understanding the inverses in this group is easy once we’ve seen a few examples, so let’s do that now.
In we have that, for example, and . The inverse of, say, 23, is 2, since modulo 25. However, in , we have that and , and now the inverse of 23 is 7 since modulo 30.
The notion of “something modulo something else” is in fact much more general than this. In fact, we can take any positive whole number and ask about “any integer modulo ” as follows. Let’s take the positive whole number 6 and the integer 85. We say that 85 is 1 modulo 6 because . In other words, what we do is take the integer that we’re asking about and “multiply up” the positive whole number that we’ve chosen as far as we can without “overshooting” the integer itself. Namely, in the above example, so that if we “multiplied up” 6 one more time, we’d “overshoot” the integer that we were interested in. Additionally, , so we could “multiply up” one more time without overshooting our integer. This is why stick with , which is as close as we can get while still staying less than 85, our integer of interest. Once we’ve done this, we simply take the remainder, i.e. what’s left, which in this case is 1. By definition of us not “overshooting” our intended integer, this remainder will always be non-negative and by definition of us getting “as close as we can get”, this remainder will always be less than 6. Note that if our integer if interest is perfectly divisible by 6 (e.g. 30) then that integer will be 0 modulo 6.
In this way we can calculate any integer modulo 6, and we find that, for example, modulo 6, modulo 6, and modulo 6. We do, however, need to be a little more careful when our integer of interest is negative. The process is the exact same, only slightly more confusing, because we need to recall what it means to be “less than” a negative number, i.e., “more negative than” a negative number. For example, modulo 6 because the largest multiple of 6 which is less than is (because zero is greater than ). Similarly, modulo 6 because the greatest multiple of 6 that is still less than is , and the non-negative remainder is then 4. We note that while this may be confusing (or it may not be), it is exactly what we would expect when we try “continuing the pattern” of “modulo” from the positive integers. Namely, 8 modulo 6 is 2, 7 modulo 6 is 1, 6 modulo 6 is 0, 5 modulo 6 is 5, 4 modulo 6 is 4, 3 mod 6 is 3, 2 mod 6 is 2, 1 mod 6 is 1, 0 mod 6 is 0, -1 mod 6 is 5, -2 mod 6 is 4, and so on, so that we get the more enlightening chart (with the integer on the left and its value modulo 6 on the right)
By examining this list we see that there is a natural pattern even when we go into the negative integers, which is in line with the fact that a clock (with any given number of hours on it) just goes around and around over and over again (in the above list, this manifested by the fact that the pattern is 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, …).
We can then add any numbers and take their value “modulo 6”, and are no longer limited to the numbers 0, 1, 2, 3, 4, and 5 as we were in the group . In fact, we can simply view the group as addition modulo 6 restricted to the elements in the set . This restricted set of numbers then turns into a group, as previously discussed.
Finally, it should be clear how to extend modular arithmetic to being “modulo any particular number,” i.e., modulo for any . For example, 85 modulo 6 is 1, as we discussed, and modulo 10 it’s 5, and modulo 30 it’s 25. The same exact logic applies as for “modulo 6”, but now with 6 replaced with any positive whole number. We’ll skip these details here, as modular arithmetic will come up a lot in the lessons, but hopefully this gives a sufficiently self-contained introduction to the subject so that we can use these ideas elsewhere.