Modular Arithmetic Instructor: Marizza Bailey Name:

Similar documents
COMP239: Mathematics for Computer Science II. Prof. Chadi Assi EV7.635

Math 131 notes. Jason Riedy. 6 October, Linear Diophantine equations : Likely delayed 6

2x 1 7. A linear congruence in modular arithmetic is an equation of the form. Why is the solution a set of integers rather than a unique integer?

Proof 1: Using only ch. 6 results. Since gcd(a, b) = 1, we have

CHAPTER 3. Congruences. Congruence: definitions and properties

2x 1 7. A linear congruence in modular arithmetic is an equation of the form. Why is the solution a set of integers rather than a unique integer?

Grade 11/12 Math Circles Rational Points on an Elliptic Curves Dr. Carmen Bruni November 11, Lest We Forget

Cool Results on Primes

Elementary Properties of the Integers

2 Arithmetic. 2.1 Greatest common divisors. This chapter is about properties of the integers Z = {..., 2, 1, 0, 1, 2,...}.

2 Elementary number theory

MATH 115, SUMMER 2012 LECTURE 4 THURSDAY, JUNE 21ST

Number Theory Proof Portfolio

MATH 433 Applied Algebra Lecture 4: Modular arithmetic (continued). Linear congruences.

For your quiz in recitation this week, refer to these exercise generators:

Clock Arithmetic. 1. If it is 9 o clock and you get out of school in 4 hours, when do you get out of school?

Part V. Chapter 19. Congruence of integers

Lecture Notes. Advanced Discrete Structures COT S

The Euclidean Algorithm and Multiplicative Inverses

Basic elements of number theory

Basic elements of number theory

Q 2.0.2: If it s 5:30pm now, what time will it be in 4753 hours? Q 2.0.3: Today is Wednesday. What day of the week will it be in one year from today?

Intermediate Math Circles February 26, 2014 Diophantine Equations I

1. multiplication is commutative and associative;

Chapter 5. Number Theory. 5.1 Base b representations

CSE 20 DISCRETE MATH. Winter

ALGEBRA. 1. Some elementary number theory 1.1. Primes and divisibility. We denote the collection of integers

Casting out Nines, and other kinds of Math Magic

Direct Proof MAT231. Fall Transition to Higher Mathematics. MAT231 (Transition to Higher Math) Direct Proof Fall / 24

MATH 2200 Final Review

Notes on Systems of Linear Congruences

Intermediate Math Circles February 29, 2012 Linear Diophantine Equations I

Know the Well-ordering principle: Any set of positive integers which has at least one element contains a smallest element.

Relations. Binary Relation. Let A and B be sets. A (binary) relation from A to B is a subset of A B. Notation. Let R A B be a relation from A to B.

WORKSHEET ON NUMBERS, MATH 215 FALL. We start our study of numbers with the integers: N = {1, 2, 3,...}

Solutions to Assignment 1

Wilson s Theorem and Fermat s Little Theorem

Math 109 HW 9 Solutions

11 Division Mod n, Linear Integer Equations, Random Numbers, The Fundamental Theorem of Arithmetic

MTH 346: The Chinese Remainder Theorem

Homework #2 solutions Due: June 15, 2012

The number of ways to choose r elements (without replacement) from an n-element set is. = r r!(n r)!.

Beautiful Mathematics

The next sequence of lectures in on the topic of Arithmetic Algorithms. We shall build up to an understanding of the RSA public-key cryptosystem.

a the relation arb is defined if and only if = 2 k, k

Number Theory Homework.

This exam contains 5 pages (including this cover page) and 4 questions. The total number of points is 100. Grade Table

1 Overview and revision

8 Primes and Modular Arithmetic

The set of integers will be denoted by Z = {, -3, -2, -1, 0, 1, 2, 3, 4, }

2.3 In modular arithmetic, all arithmetic operations are performed modulo some integer.

7.2 Applications of Euler s and Fermat s Theorem.

Wednesday, February 21. Today we will begin Course Notes Chapter 5 (Number Theory).

3 The fundamentals: Algorithms, the integers, and matrices

Elementary Number Theory. Franz Luef

4 Powers of an Element; Cyclic Groups

MATH CSE20 Homework 5 Due Monday November 4

WORKSHEET MATH 215, FALL 15, WHYTE. We begin our course with the natural numbers:

Clock Arithmetic and Euclid s Algorithm

CSE 20 DISCRETE MATH. Fall

Math Circle Beginners Group February 28, 2016 Euclid and Prime Numbers

2.2 Inverses and GCDs

MATH 501 Discrete Mathematics. Lecture 6: Number theory. German University Cairo, Department of Media Engineering and Technology.

that if a b (mod m) and c d (mod m), then ac bd (mod m) soyou aren't allowed to use this fact!) A5. (a) Show that a perfect square must leave a remain

Practice Number Theory Problems

MATH 115, SUMMER 2012 LECTURE 12

STEP Support Programme. Hints and Partial Solutions for Assignment 17

5: The Integers (An introduction to Number Theory)

Chapter 1. Greatest common divisor. 1.1 The division theorem. In the beginning, there are the natural numbers 0, 1, 2, 3, 4,...,

CIRCLES AND TABLES AND SLEEPING

Factoring. Number Theory # 2

MATH 361: NUMBER THEORY FOURTH LECTURE

Algorithms CMSC Basic algorithms in Number Theory: Euclid s algorithm and multiplicative inverse

Lecture 2. The Euclidean Algorithm and Numbers in Other Bases

MATH Fundamental Concepts of Algebra

Math 31 Lesson Plan. Day 2: Sets; Binary Operations. Elizabeth Gillaspy. September 23, 2011

Math Circle Beginners Group February 28, 2016 Euclid and Prime Numbers Solutions

Primes and Modular Arithmetic! CSCI 2824, Fall 2014!!

CHAPTER 6. Prime Numbers. Definition and Fundamental Results

An integer p is prime if p > 1 and p has exactly two positive divisors, 1 and p.

4 Number Theory and Cryptography

MATH FINAL EXAM REVIEW HINTS

PUTNAM TRAINING NUMBER THEORY. Exercises 1. Show that the sum of two consecutive primes is never twice a prime.

Table of Contents. 2013, Pearson Education, Inc.

Lecture 6: Finite Fields

Representing numbers as the sum of squares and powers in the ring Z n

Discrete Mathematics and Probability Theory Fall 2018 Alistair Sinclair and Yun Song Note 6

EUCLID S ALGORITHM AND THE FUNDAMENTAL THEOREM OF ARITHMETIC after N. Vasiliev and V. Gutenmacher (Kvant, 1972)

Chapter 1 A Survey of Divisibility 14

Chapter 7. Number Theory. 7.1 Prime Numbers

8. Given a rational number r, prove that there exist coprime integers p and q, with q 0, so that r = p q. . For all n N, f n = an b n 2

NUMBER SYSTEMS. Number theory is the study of the integers. We denote the set of integers by Z:

Outline. Number Theory and Modular Arithmetic. p-1. Definition: Modular equivalence a b [mod n] (a mod n) = (b mod n) n (a-b)

MATH 2112/CSCI 2112, Discrete Structures I Winter 2007 Toby Kenney Homework Sheet 5 Hints & Model Solutions

CSE 20 DISCRETE MATH. Winter

This is a recursive algorithm. The procedure is guaranteed to terminate, since the second argument decreases each time.

Math Circles Cryptography

1. Given the public RSA encryption key (e, n) = (5, 35), find the corresponding decryption key (d, n).

PMA225 Practice Exam questions and solutions Victor P. Snaith

CS 5319 Advanced Discrete Structure. Lecture 9: Introduction to Number Theory II

Transcription:

Modular Arithmetic Instructor: Marizza Bailey Name: 1. Introduction to Modular Arithmetic If someone asks you what day it is 145 days from now, what would you answer? Would you count 145 days, or find a quicker way? Maybe, you would note that there are 7 days in a week, and, therefore, in seven days it would be the same day as today. Then you would only have to find out how many groups of 7 fit into 145. This could be easily done by dividing 7 into 145. The answer, of course, would be 20, with 5 left over, or 145 = 7(20) + 5.. Then, it would only be necessary to count 5 days from today, and you would see that it would Saturday. You may think this knowledge would only be useful to show off to friends, but you would be mistaken. Programmers use this information to write calendar programs, and time programs, as well as others. The mathematics that is involved in this problem is called modular arithmetic. Instead of looking at a number as a value in and of itself, it is though of as a member of a remainder class relative to a number. For Example, if we wanted to compute 12 mod (5) we would see that 12 = 5(2) + 2, and therefore, 5 goes into 12 twice with remainder 2. Hence, 12 mod (5) = 2. See if you can compute the following: (a) 17 mod (3) (b) 39 mod (4) (c) 137 mod (6) (d) 234 mod (10) 1

2 (e) 365 mod (7) (f) 73 mod (52) (g) 256 mod (12) Why were the last three problems significant? Could you think of word problems that might be associated to those computations? Problem 1. How many years would it take for August 6 to be a Monday? What does it mean that 2. Modular Congruence 7 2 mod (5)? First of all, it means that the difference of 7 and 2 is a multiple of 5, i.e., 7 2 = 5k for some integer, k. Is 7 actually equal to 2. What does equivalent mean? An equivalence relation is a relation that is symmetric, reflexive and transitive. Symmetry means, since 7 2 mod (5)

then 2 7 mod (5). Reflexive means that 2 2 mod (5) and transitive means that if 2 7 mod (5) and 17 2 mod (5) then 17 7 mod (5). The modulo 5 congruence class of 2 is { 23, 18, 13, 8, 3, 2, 7, 12, 17, 22, 27,... } We call 2 the residue of this class modulo 5 and we call the congruence class, the residue class. Lemma 1. Let a, b, n Z be integers. The relation a b if and only if a b mod (n) is an equivalence relation. Proof 1. We will prove that modulo is an equivalence relation by proving that it is symmetric, reflexive and transitive. symmetry By definition, a b mod (n) implies that a b = nk for some integer k. Therefore, b a = nk = n( k) where k Z. Therefore, b a mod (n). reflexive Since a a = n(0) and 0 is an integer, then by definition, a a mod (n). transitive Suppose a b mod (n) and b c mod (n), then by definition, a b = nk 1 and b c = nk 2 Therefore, by adding both equations together, we get a b + b c = nk 1 + nk 2 Simplification and factoring yields the desired result, a c = n(k 1 + k 2 ) where k 1 + k 2 is an integer, and therefore a c mod (n). 3. Adding and Subtracting Suppose you want to add two numbers modulo m. Would you be able to just add their residues? We d like to believe that to be the case. Let s look at an Example. Example 1. Suppose you want to add 7 and 23 modulo 6. 7 + 23 = 30 mod (6) = 0 and 7 mod (6) = 1 and 23 mod (6) = 5, so 1 + 5 = 0 mod (6). 3 Well, that was nice. I hope it happens like that all the time. Let s see. Lemma 2. Let r 1 = a mod (n) and r 2 = b mod (n), then r 1 + r 2 mod (n) = a + b mod (n)

4 Proof 2. If r 1 = a mod (n), then r 1 a = nk 1. Also, r 2 = b mod (n) then r 2 b = nk 2 So if we add both equations together, we get r 1 a + r 2 b = nk 1 + nk 2 (r 1 + r 2 ) (a + b) = n(k 1 + k 2 ) where k is an integer. Therefore, by definition, (r 1 +r 2 ) = (a+b) mod (n) From this we can see that r = n r mod (n). 4. Exercises Exercise 1. Add the following and simplify: (a) 73 + 89 mod (10) (b) 93 + 47 mod (9) (c) 403 397 mod (8) (d) 1214 + 1591 mod (7) (e) 134 + 453 217 mod (12) (f) 2372 + 971 1549 mod (11) Exercise 2. Find the additive inverse of each number in the respective modulo class. (a) 5 mod (9) (b) 7 mod (12) (c) 4 mod (8) Exercise 3. Find the value(s) for x that make the equation true. (a) x + 6 = 2 mod (7) (b) x + 117 = 73 mod (125)

5 5. Multiplication and Division Lemma 3. Let r 1 = a mod (n) and r 2 = b mod (n), then r 1 r 2 mod (n) = ab mod (n) Proof 3. If r 1 = a mod (n), then a r 1 = nk 1. This is equivalent to a = nk 1 + r 1 A similar argument shows, r 2 = b mod (n) then b = nk 2 + r 2 So if we multiply both equations together, we get ab = (nk 1 + r 1 )(nk 2 + r 2 ) ab = n(nk 1 k 2 ) + r 1 nk 2 + r 2 nk 1 + r 1 r 2 ab r 1 r 2 = n(nk 1 k 2 + r 1 k 2 + r 2 k 1 ) where nk 1 k 2 + r 1 k 2 + r 2 k 1 is an integer. Therefore, by definition, (r 1 r 2 ) = (ab) mod (n) Corollary 1. IF a = b mod (n) then a n = b n mod (n). The corollary above follows from the fact that multiplication respects modulo classes. 6. Exercises Exercise 4. Compute each of the following: (a) 23 17 + 7 mod (4) (b) 121 122 123 mod (5) (c) 11 23 5 28 mod (10) (d) 514 891 mod (11) (e) 4 4 mod (5) (f) 2 4 mod (5) (g) 3 4 mod (5) (h) 2 6 mod (7) (i) 3 6 mod (7) Do you see a pattern above? What do you think is true in general?

6 Try the following: (a) 2 5 mod (6) (b) 2 7 mod (8) (c) 2 1 0 mod (11) Do you see a pattern? Would you like to change your conjecture? The proof that if p is prime, then for any nonzero number n, n p 1 = 1 mod (p) requires group theory. However, we may get a glimpse of this through the following exercises. 7. The multiplicative group modulo n 5 p Simplify mod(7) 5 1 5 5 5 2 25 4 5 3 4 5 6 5 4 6 5 2 5 5 2 5 3 5 6 3 5 1 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 What did you notice? Was there a pattern? How long was it? Let s try another one. 5 p Simplify mod(8) 5 1 5 5 5 2 25 1 5 3 1 5 5 5 4 5 5 1 What did you notice now? Was there a pattern? How long was it?

Try the same thing on a separate sheet of paper with the following numbers: (a) Powers of 3 modulo 8 7 (b) Powers of 4 modulo 8 (c) Powers of 6 modulo 8 (d) Powers of 7 modulo 8 (e) Powers of 4 modulo 7 (f) Powers of 6 modulo 7 (g) Powers of 2 modulo 7 Now we can use these patterns to find higher powers. Have you found a higher power? Do you feel the higher power? Just kidding. Let s get back to math. 8. Exercises Exercise 5. Find the remainder of the following modulo 5: (a) 2 8 (b) 3 19 (c) 4 55 (e) 19 77 (f) 14 92 17 76

8 Exercise 6. 4. (A) Find all possible residues of a perfect square modulo (B) Use the information you learned from part (A) to show that there are no solutions to the equation a 2 + b 2 = 10511. Exercise 7. Find the units digit of 9 87. 9. Challenge Problem 2 (Mathematical Circles). Find 10 10 + 10 100 + 10 1000 + + 10 10000000000 Problem 3 (AMC). What is the size of the largest subset S of {1, 2, 3,..., 50} such that no pair of distinct elements of S has a sum divisibly by 7. Problem 4. The Fibonacci sequence is defined by F 1 = F 2 = 1 and F n+2 = F n+1 + F n. Find F 2006 mod (5).

10. Multiplicative Inverses modulo n Recall the Euclidean Algorithm for finding the gcd(a, b) of two integers a and b. 9 a = bq 1 + r 1 where 0 < r 1 < q 1 b = r 1 q 2 + r 2 where 0 < r 2 < r 1 r 1 = r 2 q 3 + r 3 where 0 < r 3 < r 2 r 2 = r 3 q 4 + r 4 where 0 < r 4 < r 3... r n 3 = r n 2 q n 2 + r n 1 r n 2 = r n 1 q n 1 + r n r n 1 = r n q n+1 Recall that one stops when the last remainder is zero. The last nonzero remainder r n is the gcd(a, b) We can substitute each equation into the previous and rearrange it so that we get a linear combination of a and b equal to r n. So that we don t confuse the gcd(a, b) for any other remainder, we will henceforth denote r n = d. d = r n 2 r n 1 q n 1 d = r n 2 (r n 3 r n 2 q n 2 )q n 1 d = (r n 4 r n 3 q n 3 ) (rn 3 (r n 4 r n 3 q n 3 )q n 2 )q n 1... As you can see, we can substitute backwards until we reach the sum of multiples of a and b only. Therefore, if gcd(a, b) = d, then d = am + bk implies that there exists solutions to the equations ax d mod (b) and bx d mod (a) by reducing the equations modulo b or a, respectively. This is why only numbers relative prime to b will have multiplicative inverses. If two numbers are relatively prime, then gcd(a, b) = 1 and therefore, 1 = am + bk. If we mod out by b, then we get 1 = am mod (b) Or in other words, there is an integer, m, such that am = 1 mod (b). Therefore, m is the multiplicative inverse of a.

10 11. Exercises Exercise 8. Find the multiplicative inverse, if any, of each elements below. (a) 4 mod (10) (b) 5 mod (11) (c) 7 mod (12) (d) 3 mod (9) (e) 7 mod (10) Exercise 9. Use your new knowledge of multiplicative inverses to find the solution to the equations below, if any. (a) 2x + 3 = 6 mod (7) (b) 3x 7 = 0 mod (8) (c) 3x 2 1 = 0 mod (5) 12. Checking for divisibility by n In this section we will learn all the tricks that allow us to see if a number is divisibly by another without putting in too much work. Lemma 4 (Divisibility by 3). A number is divisible by 3 if its digits are divisibly by 3. Proof 4. Let n Z be an integer. Suppose it s base 10 representation is n = a 0 10 0 + a 1 10 1 + a 2 10 2 + a 3 10 3 + a n 10 n n is divisible by 3 if and only if n = 0 mod (3). So let s mod out the entire equation above by 3. n mod (3) = a 0 + a 1 + a 2 + a n Where did all the powers of 10 go? Well, if you remember 10 = 1 mod (3), and therefore, all powers of 10 are also 1 mod (3). Hence, a n = 0 mod (3) if and only if a 1 + a 2 + a n = 0 mod (3).

The same proof will given us n = 0 mod (9) if its digits are divisible by 9 because 10 = 1 mod (9). 11 Corollary 2. Every number is in the same residue class mod 3 as the sum of its digits. The above corollary follows from the proof, but is a more general statement. Lemma 5. A number n is divisible by 2 m if its last m digits are divisible by 2 m. Proof 5. Let n = k n=0 a n10 n. Then the last m digits can be achieved by n mod (10 m ). Suppose n = r mod (10 m ), then n = 10 m q + r where q is an integer. Since 2 is a factor of 10 then, 10 m = 2 m k for some integer k. By substitution, n = (2 m k)q + r. So as you can see, n = r mod (2 m ). Therefore, if r = 0 mod (2 m ), then the last m digits are divisible by 2 m. Since n = r mod (2 m ), then n = 0 mod (2 m ) o Corollary 3. A number n is divisible by 5 m if its last m digits are divisible by 5 m. A similar proof will result in the corollary above if you replace 2 k with 5 k. Lemma 6. A number n is divisible by 11 if the alternating sum of its digits is divisible by 11. Proof 6. Suppose n is a number whose base 10 representation is given by k n = a i (10 i ) i=0 Now if n is divisibly by 11, then n = 0 mod (11). Which means that k k a i (10 i ) mod (11) = a i (10 mod (11) i i=0 i=0 Since 10 mod (11) = 1, then the sum above becomes k n = a i ( 1) i mod (11) i=0 Therefore, n = 0 mod (11) if and only if k i=0 a i( 1) i = 0 mod (11). This is the alternating sum of the digits of n.

12 Lemma 7. A number n = k k i=0 a i(10 i i=1 ) is divisible by 7, if [ a i(10 i ) ] 10 2a 0 is divisible by 7. Proof 7. Let s assume that n = 10 k a k +10 k 1 a k 1 + +10 3 a 3 +10 2 a 2 + 10a 1 +a 0. Suppose that we apply the algorithm to n and we get a multiple of 7. 10 k 1 a k + 10 k 2 a k 1 + + 10 2 a 3 + 10a 2 + a 1 2a 0 = 0 mod (7) 3 k 1 a k + 3 k 2 a k 1 + + 2a 3 + 3a 2 + a 1 2a 0 = 0 mod (7) 3 k 1 a k + 3 k 2 a k 1 + + 2a 3 + 3a 2 + a 1 + 5a 0 = 0 mod (7) multiplying the equation by the multiplicative inverse of 5 mod (7) 3 k a k + 3 k 1 a k 1 + + 6a 3 + 2a 2 + 3a 1 + a 0 = 0 mod (7) 10 k a k + 10 k 1 a k 1 + + 10 3 a 3 + 10 2 a 2 + 10a 1 + a 0 = 0 mod (7) So if we take the units digit of n, and subtract it from the remaining digits, and the result is 0 mod (7) then n is. A similar algorithm can be used for any prime number relatively prime to 10. Why? The only difference is that you find another multiple of the units digit to subtract from the rest of the digits. 13. Exercises State whether the following numbers are divisible by 3, 9, or 11. (a) 178123 (b) 5472 (c) 332175 (d) 172271 (e) 1721271

13 State whether the following are multiples of 8. (a) 1444 (b) 83412 (c) 971352 (d) 22222220 State whether the following are multiples of 7. (a) 672 (b) 902 (c) 3976 (d) 273 Find a similar algorithm to check for divisibility for 13 14. Challenge Problems Problem 5. How many four digit palindromes are multiples of 9? Problem 6. Find a six-digit number whose first three digits are 523 such that the integer is divisibly by each 7, 8, 9.

14 Problem 7. What is the smallest 5-digit palindrome that is a multiple of 99? Problem 8. Prove that a power of 2 cannot end in four equal digits? Problem 9. The integer n is the smallest positive multiple of 15 such that every digit of n is either 0 or 8. Compute n 15. (AIME)