Section 3.5 Clock Arithmetic
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{.}\)
Example 3.5.2. 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.2.2.
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.5.1.(a). We call this arithmetic modulo \(12\text{.}\) Figure 3.5.1.(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{.}\)
Example 3.5.3. Addition \(\fmod 12\).
We formulate the computations from Example 3.5.2 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.4.10.
Example 3.5.4. Addition \(\fmod 12\).
By Theorem 3.4.10 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:
\((11+ 20)\fmod 12 \) \(= ((11 \fmod 12) + (20 \fmod 12)) \fmod 12 \) \(= (11 + 8) \fmod 12 = 19 \fmod 12 = 7\)
\((11 + 25)\fmod 12\) \(= ((11 \fmod 12) + (25 \fmod 12)) \fmod 12 \) \(= (11+ 1) \fmod 12 = 12 \fmod 12 =0\)
The second computation appears to have more steps, but the arithmetic can be much simpler. In practice we combine both approaches.
In the remainder of the section we solve every day problems with clock arithmetic.
Problem 3.5.5. \(79\) hours from \(4\) o'clock.
What time is it in 79 hours if it is 4 o'clock now ?
We have \((4+79)\fmod 12=83 \fmod 12=11\text{.}\) Thus 79 hours from now, it is 11 o'clock.
The same result can also be obtained by first computing \(79\fmod 12=7\) and then \((4+7)\fmod 12=11\fmod 12=11\text{.}\)
Try for yourself in Checkpoint 3.5.6.
Checkpoint 3.5.6. Hours from now with 12 hour clock.
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
\({\text{9 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{.}\)
Problem 3.5.7. \(110\) days from Friday.
Which day of the week is it in 110 days from today if today is Friday ?
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.
Try for yourself in Checkpoint 3.5.8.
Checkpoint 3.5.8. Days from now.
If today is Thursday. What day will it be 58 days from now?
select
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
\(\text{Saturday}\)
Similarly we can answer question about months. As there are \(12\) months in a year we compute \(\fmod 12\text{.}\)
Problem 3.5.9. \(721\) months from November.
Which month is it \(721\) months from now if this month is November?
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.
Try for yourself in Checkpoint 3.5.10.
Checkpoint 3.5.10. Months from now.
Assume it is December. What month will it be 73 months from now ?
select
January
February
March
April
May
June
July
August
September
October
November
December
\(\text{January}\)
When we use the 24 hour clock we compute \(\fmod 24\text{.}\) Use this in Checkpoint 3.5.11.
Checkpoint 3.5.11. Hours from now with 24 hour clock.
We use the 24 hour clock. Assume it is 18:00 hours. What time will it be 59 hours from now ?
select
0:00 hours
1:00 hours
2:00 hours
3:00 hours
4:00 hours
5:00 hours
6:00 hours
7:00 hours
8:00 hours
9:00 hours
10:00 hours
11:00 hours
12:00 hours
13:00 hours
14:00 hours
15:00 hours
16:00 hours
17:00 hours
18:00 hours
19:00 hours
20:00 hours
21:00 hours
22:00 hours
23:00 hours
\(\text{5:00 hours}\)
In the video in Figure 3.5.12 we review the material covered above.