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.

Blank space for you to write your work.

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 n, define n to be the set of all integers that are divisible by n. In set-builder notation, we have

n:={mm=nk for some k}.

Example 6.5.3.

Write out the set 7 in roster notation.

Blank space for you to write your work.

Example 6.5.4.

Make a conjecture about pq where p and q are distinct prime numbers. Explain how you arrive at your answer.

Blank space for you to write your work.

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 R from A to B is a subset of A×B.

Definition 6.5.6.

For each n, define the relation n on via (a,b)n if abn. We typically write anb and say that “a is congruent to b modulo n”.

For example, 1752 since 172=155. Another way to think of this: 1752 because dividing 17 by 5 yields a remainder of 2.

Note that abn if and only if n divides ab, which implies that anb if and only if n divides ab. Use this in the example below.

Example 6.5.7.

Find a number n that satisfies the following conditions:

  1. (a)

    0n<4, and

  2. (b)

    3114n.

Blank space for you to write your work.

Using this tool we can now define addition and multiplication modulo n.

Definition 6.5.8.

We define [k]n to be the set of all integers that are congruent to k modulo n. For example, [0]n={,10,5,0,5,10}. The set [5]n equals the set [0]n.

Definition 6.5.9.

Let n. We define the sum and product of congruence classes in /n via

[a]n+[b]n:=[a+b]nand[a]n[b]n:=[ab]n.

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 n where 0n<10 (the number we are taking mod with respect to). (This is customary in modular arithmetic.)

[2403+791+688+4339]10.

What is this number you calculated in terms of the sum of these four numbers?

Blank space for you to write your work.

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!

Blank space for you to write your work.

We can also compute powers of numbers quickly using modular arithmetic using the following corollary:

Corollary 6.5.12.

Let n. If a and k, then ([a]n)k=[ak]n.

Example 6.5.13.

You are given the following:

71 =7
72 =49
73 =343
74 =2401.

Compute [71942]100. (Hint: do you see a pattern in the numbers above? How about if you compute what the numbers above are equivalent to modulo 100?)

Blank space for you to write your work.

Example 6.5.14.

Prove that, for all n, [74n]100=[1]100.

Blank space for you to write your work.