4.13: Modular Arithmetic
- Page ID
- 163840
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)
( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\id}{\mathrm{id}}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\kernel}{\mathrm{null}\,}\)
\( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\)
\( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\)
\( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)
\( \newcommand{\vectorA}[1]{\vec{#1}} % arrow\)
\( \newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow\)
\( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vectorC}[1]{\textbf{#1}} \)
\( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)
\( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)
\( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)After completing this section, you should be able to:
- Add, subtract, and multiply using modulo (clock) arithmetic.
- Apply modular (clock) arithmetic to calculate real-world applications.
Online shopping requires you to enter your credit card number, which is then sent electronically to the vendor. Using an ATM involves sliding your bank card into a reader, which then reads, sends, and verifies your card. Swiping or tapping for a purchase in a brick–and-mortar store is how your card sends its information to the machine, which is then communicated to the store’s computer and your credit card company. This information is read, recorded, and transferred many times. Each instance provides one more opportunity for error to creep into the process, a misrecorded digit, transposed digits, or missing digits. Fortunately, these card numbers have a built-in error-checking system that relies on modular arithmetic, which is often referred to as clock arithmetic. In this section, we explore clock, or modular, arithmetic.
Adding, Subtracting, and Multiplying Using Modulo Arithmetic
When we do arithmetic, numbers can become larger and larger. But when we work with time, specifically with clocks, the numbers cycle back on themselves. It will never be 49 o’clock. Once 12 o’clock is reached, we go back to 1 and repeat the numbers. If it's 11 AM and someone says, “See you in four hours,” you know that 11 AM plus 4 hours is 3 PM, not 15 AM (ignoring military time for now). Math worked on the clock, where numbers restart after passing 12, is called clock arithmetic.
Clock arithmetic hinges on the number 12. Each cycle of 12 hours returns to the original time (Figure 3.42). Imagine going around the clock one full time. Twelve hours pass, but the time is the same. So, if it is 3:00, 14 hours later and two hours later both read the same on the clock, 5:00. Adding 14 hours and adding 2 hours are identical. As is adding 26 hours. And adding 38 hours.
What do 2, 14, 26, and 38 have in common in relation to 12? When they are divided by 12, they each have a remainder of 2. That's the key. When you add a number of hours to a specific time on the clock, first divide the number of hours being added by 12 and determine the remainder. Add that remainder to the time on the clock to know what time it will be.
A good visualization is to wrap a number line around the clock, with the 0 at the starting time. Then each time 12 on the number line passes, the number line passes the starting spot on the clock. This is referred to as modulo 12 arithmetic. Even though the process says to divide the number being added by 12, first perform the addition; the result will be the same if you add the numbers first, and then divide by 12 and determine the remainder.
In general terms, let be a positive integer. Then modulo 12, written ( mod 12), is the remainder when is divided by 12. If that remainder is , we would write (mod 12).
Caution: 12 mod 12 is 0. So, if a mod 12 problem ends at 0, that would be 12 on the clock.
Determining the Value of a Number modulo 12
Find the value of the following numbers modulo 12:
- 34
- 539
- 156
- Answer
-
To determine the value of a number modulo 12, divide the number by 12 and record the remainder.
- To find the value 34 modulo 12:
Step 1: Determine the remainder when 34 is divided by 12 using long division. The largest multiple of 12 that is less than or equal to 34 is 24, which is the product of 12 and 2.
Step 2: Performing the subtraction yields 10.
Since that subtraction resulted in a number less than 12, that is the remainder, 10. The value of 34 modulo 12 is 10, or 34 = 10 (mod 12).
- To find the value 539 modulo 12:
Step 1: Determine the remainder when 539 is divided by 12 using long division. We first look to the first two digits of 539, 53. The largest multiple of 12 that is less than or equal to 53 is 48, which is the product of 12 and 4.
Step 2: Performing the subtraction results in 5.
Step 3: Now, the 9 is brought down.
Step 4: The largest multiple of 12 that is less than or equal to 59 is once more 48 itself, which is .
Step 5: Finishing the process, the 48 is subtracted from the 59, yielding 11.
We've used all the digits of 539, and the last subtraction resulted in a number less than 12, so that number, 11, is the remainder. The value of 539 modulo 12 is 11, or, 539 = 11 (mod 12).
- To find the value 156 modulo 12:
Step 1: Determine the remainder when 156 is divided by 12 using long division. We first look to the first two digits of 156, 15. The largest multiple of 12 that is less than or equal to 15 is 12 itself, which is the product of 12 and 1.
Step 2: Performing the subtraction results in 3.
Step 3: Now, the 6 is brought down.
Step 4: The largest multiple of 12 that is less than or equal to 36 is 36 itself, which is .
Step 5: Finishing the process, the 36 is subtracted from the 36, yielding 0.
We've used all the digits of 156, and the last subtraction resulted in a number less than 12, so that number, 0, is the remainder. The value of 156 modulo 12 is 0, or, 156 = 0 (mod 12).
We should note here that, had we been speaking of time, the 0 would be interpreted as 12:00.
- To find the value 34 modulo 12:
- 93
- 387
Using Desmos to Determine the Value of a Number module 12
Desmos may be used to determine the value of a number modulo 12. It is flexible enough to find the value of a number modulo of any other integer you want. To determine the value of
Clock arithmetic is modulo 12 arithmetic but applied to time. As time is divided into 12 hours that repeat a cycle, we use modulo 12 for clock arithmetic.
Adding with Clock Arithmetic
If it's 3:00, what time will it be in 89 hours?
- Answer
-
To find that future time, we may determine the value of 89 (mod 12), either by long division or by using a calculator, such as Desmos. Then add the result to 3:00. Entering mod(89,12) in Desmos results in 5. Adding 5 hours, which was 89 (mod12), to 3:00 results in 8:00.
Subtracting time on the clock works in much the same way as addition. Find the value of the number of hours being subtracted modulo 12, then subtract that from the original time.
Subtracting with Clock Arithmetic
If it is 4:00 now, what time was it 67 hours ago?
- Answer
-
To find that past time, we may determine the value of 67 (mod 12), either by long division or by using a calculator, such as Desmos. Then subtract the result to 4:00. Entering mod(67,12) in Desmos results in 7. Subtracting 7 hours from 4:00 results in ‒3:00. We know, though, that time is not represented with negative times. This value, ‒3:00, indicates three hours before 12:00, which is 9:00. So, 67 hours before 4:00 was 9:00. We see this in the Figure 3.44.
Recall that clock arithmetic was referred to as modulo 12 arithmetic. Multiplying in modulo 12 also relies on the remainder when dividing by 12. To multiply modulo 12 is just to multiply the two numbers, and then determine the remainder when divided by 12.
Multiplying modulo 12
What is the product of 11 and 45 modulo 12?
- Answer
-
We begin by multiplying 11 and 45, which is 495. Next, we find 495 modulo 12, either by dividing the result by 12 to determine the remainder, or by using a calculator. Entering mod(495,12) in Desmos yields 3. Had long division been used, the remainder would be 3. So modulo 12.
Calculating Real-World Applications with Clock Arithmetic
Applying Clock Arithmetic
Suppose it is 3:00, and you decide to check your email every 5 hours. What time will it be when you check your email the ninth time?
- Answer
-
If you check your email every 5 hours nine times, that ninth check will occur 45 hours after 3:00, which is an addition of 45 hours to 3:00. So, we find 45 modulo 12, which is 9. Nine hours after 3:00 is 12:00. It will be 12:00 when you check your email the ninth time.
Clock arithmetic processes can be applied to days of the week. Every 7 days the day of the week repeats, much like every 12 hours the time on the clock repeats. The only difference will be that we work with remainders after dividing by 7. In technical terms, this is referred to as modulo 7. More generally, let be a positive integer. Then modulo 7, written mod 7, is the remainder when is divided by 7. If that value is , we may write (mod 7).
Applying Clock Arithmetic to Days of the Week
Your family has a cat, and no one wants to empty the litter box. However, it has to be done daily. The six of you agree to take turns, so everyone has to empty the litter box every 6 days. You empty the box on a Thursday. What day will you empty the box for the 10th time?
- Answer
-
The first time you emptied the litter box was on a Thursday. So,the 10th time you empty the litter box will be 9 times later (you've already had your first turn, so 9 turns left!). This will happen 54 (9 times 6) days later. Finding the value of 54 modulo 7, using division to determine the remainder or using a calculator to find the value of 54 modulo 7 gives the answer 5. Five days after a Thursday is Tuesday.
Check Your Understanding
- \(7+19\)
- \(8-31\)
- \(5 \times 37\)
- Calene calls her mother every fourth day. She calls on a Monday. What day of the week will it be on Calene's eighth time calling after that?
Section \(PageIndex{}\) Exercises
- Explain what modulo 12 means.
- Explain what modulo 7 means.
- What is 75 modulo 12?
- What is 139 modulo 12?
- What is 38 modulo 7?
- What is 83 modulo 7?
For the following exercises, use clock arithmetic (mod 12), to perform the indicated calculation. - \(7 + 13\)
- \(8 + 19\)
- \(4 + 27\)
- \(3 + 100\)
- \(9 - 15\)
- \(6 - 27\)
- \(4 \times 18\)
- \(7 \times 29\)
- \(11 \times 38\)
- \(6 \times 23\)
- It is 8:00. What time will it be in 70 hours?
- It is a Thursday. What day of the week will it be in 100 days?
- It is Monday. What day of the week will it be in 58 days?
- It is 3:00. What time of the day will it be in 150 hours?
- It is 6:00. What time was it 34 hours ago?
- It is 2:00. What time was it 100 hours ago?
- A trucker passes through Kokomo, Indiana, once every 9 days. They come through Kokomo on a Wednesday. What day of the week will the driver pass through Kokomo after 8 more visits?
- Jason checks his email every 5 hours. He checks it at 6 PM one day. What time of the day will it be when he checks his mail the 50th time after that 6 PM check?
- Mickey gets a new prescription of a drug that she needs to take every day. The prescription is for 250 days. She takes the first pill of the new bottle on a Friday. What day of the week will her prescription run out?
- Zainab visits the nursing home every 5 days. She visits on a Sunday. What day of the week will it be when she visits it for the 7th time after that?
- Micaela has to check in with her boss every 14 hours. If she checks in at 3:00, what time will it be when she checks in the 10th time after that?
- Tracy has an alarm set for every 4 hours. It goes off at 3:00. What time will it be when the alarm goes off the 20th time after that?
- Dejan must check his blood sugar every 5 hours. He checks his blood sugar at 4:00. What time will it be when Dejan checks their his sugar the 40th time after that?
- Latanjana is in the hospital, where her blood pressure is checked every 3 hours. If her blood pressure is checked at 5:00, what time will it be when her blood pressure is checked the 13th time after that?Months come in twelves, just as hours do. This means that months can be calculated using modulo 12, just like hours. For the following exercises, calculate what month it will be for each exercise.
- Micaela works for a sprinkler maintenance company and runs a routine check on the Harris's sprinkler system every third month. If Micaela checks the system in an April, what month will it be when Micaela returns to the Harris's for the 11th time after that?
- Dana runs a half marathon every 5 months. She runs one in a May. What month will it be when she runs her 8th marathon after that?