In the following we give applications of the combination of the operation \(\bmod\) and the addition of integers called clock arithmetic.
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{.}\)
Example3.62.12 hour clock.
When using the 12 hour clock we have:
An hour after 11 o’clock it is 12 o’clock.
Two hours after 11 o’clock it is 1 o’clock.
10 hours after 11 o’clock it is 9 o’clock.
20 hours after 11 o’clock it is 7 o’clock.
25 hours after 11 o’clock it is 12 o’clock.
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{.}\)
Example3.63.Addition \(\fmod 12\).
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{.}\)
\(\displaystyle (11+1)\fmod 12=12\fmod 12=0\)
\(\displaystyle (11+2)\fmod 12=13\fmod 12 =1\)
\(\displaystyle (11+10)\fmod 12=21\fmod 12 =9\)
\(\displaystyle (11+20)\fmod 12=31\fmod 12 =7\)
\(\displaystyle (11+25)\fmod 12=36\fmod 12 =0\)
When the numbers are larger than \(12\) we can simplify our computations by applying Theorem 3.46.
Example3.64.Addition \(\fmod 12\).
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:
We use the 12 hour clock. Assume it is 8 o’clock. What time will it be 49 hours from now ?
select
12 o’clock
1 o’clock
2 o’clock
3 o’clock
4 o’clock
5 o’clock
6 o’clock
7 o’clock
8 o’clock
9 o’clock
10 o’clock
11 o’clock
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{.}\)
Problem3.67.\(110\) days from Friday.
Which day of the week is it in 110 days from today if today is Friday ?
Solution.
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.
If today is Thursday. What day will it be 58 days from now?
select
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
Similarly we can answer question about months. As there are \(12\) months in a year we compute \(\fmod 12\text{.}\)
Problem3.69.\(721\) months from November.
Which month is it \(721\) months from now if this month is November?
Solution.
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.