CS Unplugged activity
Clocks That Wrap Around: the modulo idea
Some numbers wrap around instead of growing forever, like the hands on a clock. This wraparound trick is called modulo, and computers use it all the time. You’ll count around a few clocks, then predict a computer’s own version of it.
Learn more: clocks are one example of modular arithmetic, a whole branch of math built on wraparound counting.
- Look at the clock below. It has 10 spots, numbered 0 to 9.
- Start at the number you’re given.
- Count forward that many steps around the circle, going past 9 back to 0.
- Write down the spot where you land.
- Check yourself: it’s always the last digit of start + steps added normally.
For example: start at 7, count forward 4 steps: 8, 9, 0, 1. You land on 1. Quick check: 7 + 4 = 11, and 1 is the last digit of 11. That will always work on this clock, because it only has 10 spots.
Count forward
| Start at | Count forward | Land on |
|---|---|---|
| 2 | 3 steps | |
| 6 | 5 steps | |
| 3 | 47 steps |
Counting backward
Counting backward works the same way, just going the other direction. Past 0, you wrap around to 9 instead.
For example: start at 2, count backward 5 steps: 1, 0, 9, 8, 7. You land on 7.
| Start at | Count backward | Land on |
|---|---|---|
| 3 | 5 steps | |
| 5 | 13 steps |
Other clocks
The same wraparound idea works for any size clock, not just 10. Here are five you already use in real life.
| It is 9 o'clock. What time is it 6 hours later? | |
| Today is Thursday (day 4). What day is it 10 days from now? | |
| Is 17 even or odd? | |
| 24-hour & 360° | A 24-hour clock wraps from 23 back to 0; a full turn (360°) works the same way. A movie starts at 22:00 and runs for 3 hours. What time does it end? You spin a dial 370 degrees, starting at 0. Where does it point, as a number from 0 to 359? |
Predicting a computer’s version
Python, a programming language, writes this exact same idea as %. 17 % 5 means “count forward 17 steps on a 5-spot clock (0, 1, 2, 3, 4), starting at 0. Where do you land?” Try it: 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2. That’s 17 steps, landing on 2. So 17 % 5 is 2.
| Expression | Predict the value |
|---|---|
20 % 7 | |
5 % 8 | |
7 % 2 |
Count forward. 2+3→5. 6+5→1. 3+47→0.
Counting backward. 3−5→8. 5−13→2.
Other clocks. 12-hour clock: 3 o’clock. 24-hour clock: 01:00. Days of the week: Sunday. Degrees in a circle: 10 degrees. Even and odd: Odd (position 1).
Predicting %. 20 % 7 = 6. 5 % 8 = 5. 7 % 2 = 1.
Version history
- Loading commit history…