Modular Arithmetic on a Clock Face

Remainders bend the number line into a circle.

Past 12, the clock starts again

It is 9 o'clock. What time will it be in 5 hours? Count on round the clock face: 10, 11, 12, 1, 2. It will be 2 o'clock.

Ordinary addition says 9 + 5 = 14, but no 12-hour clock shows 14. After 12, the hour hand starts round the numbers again, so 14 hours on the clock is the same as 2.

15210315420525630735840945105011551209:009 o'clock

9:00 = 9 o'clock: the long hand is on 12 and the short hand points straight at 9

Set the clock to 2:00

The clock opens at 9:00. Turn the minute hand forward five full turns, one for each hour, and the hour hand passes 12 and stops at 2.

Keep only the remainder

Every 12 hours the hour hand makes one full turn and comes back to where it started, so a full 12 hours changes nothing on the clock. Only what is left over after the full turns moves the hand.

That is the remainder after dividing by 12. 14 = 1 × 12 + 2: one full turn, and 2 hours left over. We write 14 mod 12 = 2, which is read "14 mod 12 is 2". Working with remainders in this way is called modular arithmetic.

A larger number works the same way. 10 o'clock plus 40 hours: 10 + 40 = 50, and 50 = 4 × 12 + 2, so 50 mod 12 = 2. Four full turns change nothing, and the clock shows 2 o'clock.

One difference in naming: 24 mod 12 = 0, because 24 is exactly 2 full turns. Modular arithmetic writes that remainder as 0, and the clock face writes it as 12.

024681012141618202224+5−129142

On a number line, 9 + 5 lands at 14. Taking away one full 12 lands at 2, which is where the clock points: 14 mod 12 = 2.

The modulus

The number after mod is called the modulus. On the clock the modulus is 12, but any whole number can be the modulus.

Take the modulus 5. Dividing by 5 can only leave the remainders 0, 1, 2, 3 and 4, so every whole number lands on one of those five. Count 0, 1, 2, 3, 4, and the next number, 5, leaves remainder 0 and lands back at the start. The number line has been bent into a circle.

17 = 3 × 5 + 2, so 17 mod 5 = 2. Counting 17 steps round the circle from 0 goes round three full times and then 2 more steps, ending at 2.

01234

Mod 5, the remainders 0, 1, 2, 3 and 4 sit round a circle. One step on from 4 comes back to 0, because 5 mod 5 = 0.

Finding a remainder

To find 38 mod 7, take away as many whole 7s as fit into 38. 5 × 7 = 35 fits, and 6 × 7 = 42 does not. So 38 = 5 × 7 + 3, and 38 mod 7 = 3.

The answer is always one of 0, 1, 2 and so on up to one less than the modulus. If it is not, another whole 7 can still be taken away.

Calendars work the same way

The days of the week repeat every 7 days, so a calendar works mod 7. What day is it 30 days after a Monday? 30 = 4 × 7 + 2. The 4 full weeks bring the day back to Monday, and 2 more days make it Wednesday.

The remainder can be found before adding. What time is it 29 hours after 8 o'clock? 29 = 2 × 12 + 5, so 29 hours moves the clock as far as 5 hours does. 8 + 5 = 13, and 13 mod 12 = 1, so it will be 1 o'clock. Adding first gives the same answer: 8 + 29 = 37 = 3 × 12 + 1.

Worked example: The Day of the Week After 100 Days and a Clock After 50 Hours

Question A cargo ship leaves port on a Wednesday, and its voyage takes exactly 100 days. (a) On which day of the week does the ship arrive? (b) The 12-hour clock on the bridge shows 9 o'clock when a storm warning is received. The storm is expected 50 hours later. What time does the clock show when the storm is expected?

  1. 1.The days of the week repeat every 7 days, so 7 days after a Wednesday is a Wednesday again. Only the remainder when 100 is divided by 7 changes the day.

    SunMonTueWedThuFriSatthe days repeat every 7 days
    SunMonTueWedThuFriSatthe days repeat every 7 days
    7 days after a Wednesday is a Wednesday again, so only the remainder of 100 on division by 7 changes the day.
  2. 2.Divide 100 by 7: 14 × 7 = 98, so 100 = 14 × 7 + 2. The 14 full weeks bring the ship back to a Wednesday, and 2 days are left over.

    SunMonTueWedThuFriSatthe days repeat every 7 days100 = 14 × 7 + 214 full weeks change nothing
    SunMonTueWedThuFriSatthe days repeat every 7 days100 = 14 × 7 + 214 full weeks change nothing
    100 = 14 × 7 + 2: there are 14 full weeks and 2 days left over.
  3. 3.(a) Count 2 days on from Wednesday: Thursday, Friday. The ship arrives on a Friday.

    SunMonTueWedThuFriSat+ 2100 = 14 × 7 + 22 days after Wednesday: Friday
    SunMonTueWedThuFriSat+ 2100 = 14 × 7 + 22 days after Wednesday: Friday
    (a) 2 days on from Wednesday is Friday.
  4. 4.A 12-hour clock repeats every 12 hours. Divide 50 by 12: 4 × 12 = 48, so 50 = 4 × 12 + 2. The 4 full turns of the hour hand change nothing, and 2 hours are left over.

    121234567891011the clock repeats every 12 hours50 = 4 × 12 + 2
    121234567891011the clock repeats every 12 hours50 = 4 × 12 + 2
    A 12-hour clock repeats every 12 hours, and 50 = 4 × 12 + 2.
  5. 5.(b) 9 + 2 = 11, so the clock shows 11 o'clock. Check: 9 + 50 = 59 and 59 = 4 × 12 + 11, which also gives 11 o'clock.

    121234567891011+ 250 = 4 × 12 + 29 + 2 = 11 o'clockcheck: 9 + 50 = 59 = 4 × 12 + 11
    121234567891011+ 250 = 4 × 12 + 29 + 2 = 11 o'clockcheck: 9 + 50 = 59 = 4 × 12 + 11
    (b) 9 + 2 = 11, so the clock shows 11 o'clock.

Answer: (a) Friday, because 100 = 14 × 7 + 2; (b) 11 o'clock

Common mistakes

  • Using the quotient instead of the remainder, and counting 14 days on from Wednesday. The quotient 14 is the number of full weeks, and a full week does not change the day. The remainder 2 is the number of days to count on.
  • Dividing 50 hours by 24 because a day has 24 hours. The clock on the bridge is a 12-hour clock, so its hour hand returns to the same number every 12 hours, and the division is by 12.

More number theory problems, worked step by step →

The usual mistakes

Taking away the modulus only once. 38 − 7 = 31, but 31 is still more than 7, so it is not the remainder. Keep taking away 7s until what is left is less than 7.

Measuring up to the next multiple instead. 42 − 38 = 4 is how far 38 is below the next multiple of 7. The remainder counts on from the multiple below: 38 − 35 = 3.

Using the quotient instead of the remainder. In 30 = 4 × 7 + 2, the 4 counts full weeks, which do not change the day. The day moves on by the remainder, 2.

Practice Modular Arithmetic on a Clock Face in the app