Recall that the operation \(\fmod\) yields the remainder of integer division. That is, for an integer \(a\) and a natural number \(b\) the number \(r=a\fmod b\) is the number such that \(a=(q\cdot b)+r\) for some integer \(q\) and \(r\) is a non-negative integer and \(r \lt b\text{.}\)
Applications of the operation \(\bmod\) can be found in arithmetic with hours, days of the week, and months. We start with examples of adding hours and then relate this to using addition and the operation \(\fmod\text{.}\)
(b)We wrap the number line (compare Figure 1.2) around a circle such that all numbers with the same remainder from division by 12 are in the same position.
These operations can be considered as adding hours to a time. To compute these additions we add the hours and then subtract \(12\) as many times as necessary to obtain a number between \(1\) and \(12\text{.}\) With a similar method we had computed the remainder in Algorithm 3.6.
The main difference between the two approaches is that using the \(12\) hour clock we obtain numbers between \(1\) and \(12\) and when computing remainders we obtain numbers between \(0\) and \(11\text{.}\) That is, we replace \(12\) by \(0\text{,}\) as shown in Figure 3.61.(a). We call this arithmetic modulo \(12\text{.}\)Figure 3.61.(b) illustrates how the number line wraps around the clock face in arithmetic modulo \(12\text{.}\) The remainder modulo \(12\) of two numbers is the same if they differ by a multiple of \(12\text{.}\)
We formulate the computations from Example 3.62 using remainders. Recall that we denoted the remainder of the division of \(a\) by \(12\) by \(a\fmod 12\text{.}\)
By Theorem 3.46 that we can add first or take the remainder first, and we will get the same answer, so in Item 4 and Item 5 above, we could have done the following:
Everything we have done for hours above also works for other counts that wrap around. For example, when answering questions about weekdays we compute \(\fmod 7\text{.}\)
The days of the week wrap around after seven days. When adding days and we want the result as a weekday, any multiples of 7 do not change the day of the week. Instead of adding 110 days we add \(110\fmod 7=5\) days. So 110 days after Friday is the same day of the week as 5 days after Friday, namely Wednesday.
Months wrap around after \(12\) months. We have \(721\fmod 12=1\text{.}\) Since December is one month after November, \(721\) months from now, it will be December.