SUCCEED

   

Forensic Science
Shodor > SUCCEED > Curriculum > Workshops > Forensic Science

Introduction to Modular Arithmetic

Using a projector, navigate to the Clock Arithmetic applet. Before using, discuss the applet.

  • What does this look like?
  • How many hours are on a clock?
  • Why?
  • Why do we need 12 hours on the clock just because we count days in 12-hour sections?
  • What kind of math problems do you think we could use this applet to solve?
  • Suppose it's 9 o'clock, and I want to meet my friend in 5 hours. What time will that be?
  • How can we go about solving this problem?
As a class, set the starting time to 9. Then set the elapsed hours to 5. Press "move forward", and discuss the results.
  • What was the answer we got?
  • I would have expected us to get 14. Why didn't we?
  • Why do we start back over at 0 when we get to the 12?

Explain that this is "modular arithmetic". It focuses on remainders. In the situation before, we add 5 hours to our start time to get 14 hours. But then we do "14 mod 12". Does anybody know what that means? Can anybody guess?

"14 mod 12" means you take the first number and divide it by the second number. We don't care about the quotient in this case. That's how many times it's gone around the clock, and it's not important for this problem. Does anybody know what we do care about?

Modular arithmetic focuses on remainders. All you're really looking for is the remainder. Let's try another problem: 29 mod 7. What's the answer? Let's work through it: 29 divided by 7... we know that 28 is a multiple of 7, and 29 is 1 greater than 28. So the answer is 1.

Let's think about a different problem. Suppose that my birthday is on a Friday last year. And I want to know what day my birthday will be on next year, how could I solve it? Can we use modular arithmetic? Solve the problem by setting the clock to 7, since there are 7 days in a week. Set the start time to 6, since Friday is the 6th day of the week. Now set the elapsed time to 365 since there are 365 days in a year (most of the time). Have the applet calculate for you. Meanwhile, complete the long division by hand to make sure it's done correctly. The remainder will be 1, which is why the applet will finish on 7. (To just calculate the remainder, set the start time to 0.)

All of that is really neat, but what does it have to do with coding messages? Can anybody guess? If students are having trouble, set the clock size to 26 as a hint. Help students realize that they could use each number to represent a letter, and encode messages that way.