6.5 Modular Arithmetic
Objectives:
-
•
Determine properties of modular arithmetic
-
•
Compute answers to difficult arithmetic problems using congruence classes
Example 6.5.1.
What is the day of the week (Monday, Tuesday, Wednesday,…) 1000 days after today? Explain how you found your answer.
Before we continue learning about abstract concepts like sets and functions, it is important that we see the connections of these concepts to real-world logic problems. Sometimes large computational problems like the one in the above example can be solved without pulling out several years of calendars and counting to 1000! We can save time and energy using a concept called modular arithmetic.
Definition 6.5.2.
For each , define to be the set of all integers that are divisible by . In set-builder notation, we have
Example 6.5.3.
Write out the set in roster notation.
Example 6.5.4.
Make a conjecture about where and are distinct prime numbers. Explain how you arrive at your answer.
To define what is so “modular” about modular arithmetic, we will need the concept of a relation. We will discuss relations more in Chapter 7. For now, consider it merely as a way to “relate” numbers to one another, categorizing them into various classes of numbers.
Definition 6.5.5.
A relation from to is a subset of .
Definition 6.5.6.
For each , define the relation on via if . We typically write and say that “ is congruent to modulo ”.
For example, since . Another way to think of this: because dividing 17 by 5 yields a remainder of 2.
Note that if and only if divides , which implies that if and only if divides . Use this in the example below.
Example 6.5.7.
Find a number that satisfies the following conditions:
-
(a)
, and
-
(b)
.
Using this tool we can now define addition and multiplication modulo .
Definition 6.5.8.
We define to be the set of all integers that are congruent to modulo . For example, . The set equals the set .
Definition 6.5.9.
Let . We define the sum and product of congruence classes in via
Let us see how we can use these relations to categorize numbers.
Example 6.5.10.
Calculate the following without adding the four numbers given below. Write your answer as a number where (the number we are taking mod with respect to). (This is customary in modular arithmetic.)
What is this number you calculated in terms of the sum of these four numbers?
Example 6.5.11.
Find the remainder when the difference between 60002 and 601 is divided by 6. Use modular arithmetic - do not actually subtract and divide!
We can also compute powers of numbers quickly using modular arithmetic using the following corollary:
Corollary 6.5.12.
Let . If and , then .
Example 6.5.13.
You are given the following:
Compute . (Hint: do you see a pattern in the numbers above? How about if you compute what the numbers above are equivalent to modulo 100?)
Example 6.5.14.
Prove that, for all , .