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?

Similar documents
CHAPTER 3. Congruences. Congruence: definitions and properties

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

Discrete Mathematics and Probability Theory Summer 2014 James Cook Note 5

Number Theory. CSS322: Security and Cryptography. Sirindhorn International Institute of Technology Thammasat University CSS322. Number Theory.

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

Number Theory in Problem Solving. Konrad Pilch

Winter Camp 2009 Number Theory Tips and Tricks

Discrete Mathematics and Probability Theory Fall 2013 Vazirani Note 3

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

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

Math From Scratch Lesson 20: The Chinese Remainder Theorem

Numbers. Çetin Kaya Koç Winter / 18

Lecture Notes. Advanced Discrete Structures COT S

Number Theory. Zachary Friggstad. Programming Club Meeting

Chapter 5. Number Theory. 5.1 Base b representations

CPSC 467b: Cryptography and Computer Security

Math101, Sections 2 and 3, Spring 2008 Review Sheet for Exam #2:

CHAPTER 6. Prime Numbers. Definition and Fundamental Results

Lesson 21 Not So Dramatic Quadratics

3.2 Solving linear congruences. v3

CPSC 467: Cryptography and Computer Security

Cool Results on Primes

Math Lecture 18 Notes

Continuing discussion of CRC s, especially looking at two-bit errors

Number theory (Chapter 4)

Number Theory. Modular Arithmetic

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?

Modular Arithmetic Instructor: Marizza Bailey Name:

Elementary Properties of the Integers

Discrete Mathematics and Probability Theory Fall 2014 Anant Sahai Homework 5. This homework is due October 6, 2014, at 12:00 noon.

All variables a, b, n, etc are integers unless otherwise stated. Each part of a problem is worth 5 points.

Section 0.6: Factoring from Precalculus Prerequisites a.k.a. Chapter 0 by Carl Stitz, PhD, and Jeff Zeager, PhD, is available under a Creative

CSC 474 Information Systems Security

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?

Number Theory and Group Theoryfor Public-Key Cryptography

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

A Guide to Arithmetic

Solution Sheet (i) q = 5, r = 15 (ii) q = 58, r = 15 (iii) q = 3, r = 7 (iv) q = 6, r = (i) gcd (97, 157) = 1 = ,

Lecture 7: Number Theory Steven Skiena. skiena

Applied Cryptography and Computer Security CSE 664 Spring 2018

Homework #2 solutions Due: June 15, 2012

AN ALGEBRA PRIMER WITH A VIEW TOWARD CURVES OVER FINITE FIELDS

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

COMS W4995 Introduction to Cryptography September 29, Lecture 8: Number Theory

MATH 115, SUMMER 2012 LECTURE 12

Exam 2 Solutions. In class questions

Number Theory Alex X. Liu & Haipeng Dai

Math 109 HW 9 Solutions

Discrete Mathematics and Probability Theory Summer 2017 Course Notes Note 6

The Euclidean Algorithm and Multiplicative Inverses

Lecture 2. The Euclidean Algorithm and Numbers in Other Bases

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

Introduction. What is RSA. A Guide To RSA by Robert Yates. Topics

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.

Math Lecture 23 Notes

CHMC: Finite Fields 9/23/17

Math Circles Cryptography

#26: Number Theory, Part I: Divisibility

Mathematical Foundations of Cryptography

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

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

Definition For a set F, a polynomial over F with variable x is of the form

Lecture 4: Number theory

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?

Modular Arithmetic Investigation

Commutative Rings and Fields

MATH 361: NUMBER THEORY FOURTH LECTURE

ACCESS TO SCIENCE, ENGINEERING AND AGRICULTURE: MATHEMATICS 1 MATH00030 SEMESTER /2018

Olympiad Number Theory Through Challenging Problems

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

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

1 Overview and revision

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

cse 311: foundations of computing Fall 2015 Lecture 12: Primes, GCD, applications

Basic elements of number theory

Basic elements of number theory

Lecture notes: Algorithms for integers, polynomials (Thorsten Theobald)

Number Theory. Everything else. Misha Lavrov. ARML Practice 10/06/2013

Integers and Division

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

Algorithms (II) Yu Yu. Shanghai Jiaotong University

Elementary Number Theory MARUCO. Summer, 2018

Contest Number Theory

Math Lecture 3 Notes

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

Clock Arithmetic and Euclid s Algorithm

Q: How can quantum computers break ecryption?

A Few Primality Testing Algorithms

= 1 2x. x 2 a ) 0 (mod p n ), (x 2 + 2a + a2. x a ) 2

Part IA Numbers and Sets

EULER S THEOREM KEITH CONRAD

Intermediate Math Circles February 29, 2012 Linear Diophantine Equations I

Quiz 07a. Integers Modulo 12

To factor an expression means to write it as a product of factors instead of a sum of terms. The expression 3x

3 The fundamentals: Algorithms, the integers, and matrices

CMPUT 403: Number Theory

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

Math 1302 Notes 2. How many solutions? What type of solution in the real number system? What kind of equation is it?

Algebra. Here are a couple of warnings to my students who may be here to get a copy of what happened on a day that you missed.

The RSA public encryption scheme: How I learned to stop worrying and love buying stuff online

Transcription:

2 Mod math Modular arithmetic is the math you do when you talk about time on a clock. For example, if it s 9 o clock right now, then it ll be 1 o clock in 4 hours. Clearly, 9 + 4 1 in general. But on a clock something special happens whenever a 12 shows up: we replace it with 0. This is called doing math modulo 12 or mod 12. [9 + 4] 12 = [12 + 1] 12 = [0 + 1] 12 = [1] 12 Of course, there s nothing special about the number 12. Why not have a clock with 11 numbers, or 30, or 5? On a clock with only 5 numbers, [3] 5 + [4] 5 = [3 + 4] 5 = [7] 5 = [2] 5. The numbers you deal with mod M are between 0 and M 1. But it s perfectly fair to say = [ 8] 5 = [ 3] 5 = [2] 5 = [7] 5 = [12] 5 = [17] 5 = [22] 5 =. These numbers are said to be congruent mod 5. There are a couple ways to think about congruent numbers. Each of the following are equivalent: i) [A] M = [B] M ii) the remainder of A M = the remainder of B M iii) M (A B) iv) A = jm + x, B = km + x, for some j and k When looking at a number between 0 and M 1 it ll be alright to drop the brackets. This means that the mod and the remainder operations are the same. So for example, [7] 5 = 2. Q 2.0.1: [1498766367828] 10 =? 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? Q 2.0.4: By definition, i 2 = 1. i 58763 =? 2.1 Properties For any modulus M: 1) [M] M = 0 (By definition) 2) [A] M + [B] M = [A + B] M 3) [A] M [B] M = [A B] M Another way to think about arithmetic mod M is to think of every number as jm +x, and taking the mod just means ignoring the jm. In what follows (and in general) means equivalent to. Proof of 2) 1

[A] M + [B] M (jm + A) + (km + B) = (j + k)m + (A + B) [A + B] M Proof of 3) [A] M [B] M (jm + A)(kM + B) = jkm 2 + jmb + kma + AB = (jkm + jb + ka)m + AB [AB] M Q 2.1.1: Do these properties still hold when M is merely a rational number? What about irrational? Prove it. A quick way to find a sum is to do all the addition inside the mod, instead of add everything and then taking the mod. The advantage is that you never have to deal with really difficult math, like 2-digit numbers. For example, for [5 + 8 + 4 + 7 + 3 + 9 + 2] 7 : [5 + 8 + 4 + 7 + 3 + 9 + 2] 7 = [5 + 1 + 4 + 0 + 3 + 2 + 2] 7 Take the mod of each term = [5 + 1 + 4 + 3 + 2 + 2] 7 = [5 + 1 + 4 + 3 + 4] 7 = [5 + 1 + 4] 7 [4 + 3] 7 = [7] 7 = [0] 7 = [5 + 5] 7 = [3] 7 [5 + 5] 7 = [10] 7 = [3] 7 = 3 Q 2.1.2: You may already know that you can find the remainder of a number divided by 3 or 9 by adding up the digits. Now we ll prove it. -What is [10 k ] 9 for each value of k? Find a pattern, then prove it. -When a number is written as 1432 what is really meant is 1 10 3 +4 10 2 +3 10+2 10 0. In general, a base 10 number can be written as a 0 + a 1 10 + a 2 10 2 + + a n 10 n. Using the properties of mod math, show that [a n 10 n + a n 1 10 n 1 + + a 1 10 1 + a 0 ] 9 = [a n + a n 1 + + a 1 + a 0 ] 9. Q 2.1.3: Find the remainder of 4701135 when divided by 9. Q 2.1.4: Make up any 5 digit number. Create a second number by rearranging the digits. Now find the difference between them mod 9. Why did you get that answer? Q 2.1.5: Try to construct the same kind of trick for mod 11, as was found in 2.1.2. Con- 2

struct a similar technique (looking at powers of 10), and use it to find [1498766367828] 11. Q 2.1.6: -Say you have a number written in binary notation. Find a quick way of finding out whether or not it s divisible by 3. -When is 2 n 1 divisible by 3? Q 2.1.7: If you are writing base 8, what numbers can you find an easy divisibility test for, based on the digits? Mod math can apply to variables and numbers the same. For example, [x 3 ] 3 = [x 3 + 3x 2 ] 3 = [x 3 + 3x 2 27x 5 ] 3, because [3] 3 = [0] 3. As with everything else from now on, x is an integer. Example: You can show that [x 5 x] 5 = 0. The only things that x can be are x = 0, 1, 2, 3, 4. So, what we re looking for is a polynomial that s zero for every value of x. Starting with the most obvious choice: [x(x 1)(x 2)(x 3)(x 4)] 5 = [x(x 1)(x 2)(x + 2)(x + 1)] 5 [ 4] 5 = [1] 5, [ 3] 5 = [2] 5, and modding can pass through both addition and multiplication = [x(x 2 1)(x 2 4)] 5 = [x(x 2 1)(x 2 + 1)] 5 [ 4] 5 = [1] 5 = [x(x 4 1)] 5 = [x 5 x] 5 Q 2.1.8: Show that [(x + 3) 4 ] 4 = [(x 2 + 1) 2 ] 4. Q 2.1.9: Using the binomial expansion theorem, show that [(X + a) p ] p = [X p + a p ] p, where p is prime. Q 2.1.10: -Show that if gcd(x, N) = 1, then [ax] N = [bx] N if and only if [a] N = [b] N. -Why is this not the case if gcd(x, N) 1? 2.2 Fast Exponentiation Properties 2 and 3 basically say that taking the mod and either multiplication or addition can be done in either order. That is, you can take the mod and then multiply, or you can multiply and then take the mod. For example, [13 44] 6 = [1 44] 6 = [1 2] 6 = [2] 6 = 2 This is useful because you can replace large numbers with smaller numbers before you add or multiply. However, the same does not hold true for exponents. For example: Exponentiating, then modding: [2 7 ] 5 [128] 5 = [3] 5 = 3. 3

Modding, then exponentiating: [2 7 ] 5 [2 2 ] 5 = [4] 5 = 4. So, [2 7 ] 5 [2 2 ] 5. If you have an exponent, you have to leave it as it is. There are a few tricks to dealing with exponents, but they re a little more complicated than properties 2 and 3. First, there s a quick way to find large powers of numbers in mod math. If you re trying to find [x N ] M, and N is very large, then doing all N multiplications may take a tremendously long time. Instead, you can square over and over to find [x 2 ] M, [(x 2 ) 2 ] M, [((x 2 ) 2 ) 2 ] M,... (which is [x 2 ] M, [x 4 ] M, [x 8 ] M, [x 16 ] M,...) Q 2.2.1: Find [7 1 ] 15, [7 2 ] 15, [7 4 ] 15, [7 8 ] 15, [7 16 ] 15, [7 32 ] 15, and [7 64 ] 15. Q 2.2.2: Use what you found in the last question to find [7 20 ] 15, [7 35 ] 15, and [7 85 ] 15. So, once you know the binary expansion you can fast-exponentiate for any N. The binary expansion is pretty easy to find. All you have to do is find the largest power of 2 that s smaller than or equal to N, subtract it, and repeat. Example: Express 570 as a sum of powers of 2. 2 0 = 1 2 1 = 2 2 2 = 4 2 3 = 8 2 4 = 16 2 5 = 32 2 6 = 64 2 7 = 128 2 8 = 256 2 9 = 512 2 10 = 1024 So, 570=512+32+16+8+2. 512 < 570 < 1024 570 = 512 + 58 32 < 58 < 64 570 = 512 + 32 + 26 16 < 26 < 32 570 = 512 + 32 + 16 + 10 8 < 10 < 16 570 = 512 + 32 + 16 + 8 + 2 2 = 2 1 done Example: [3 704 ] 19 =? First you find that 704 = 512 + 128 + 64 + 8 + 2. 4

[3 2 ] 19 = [9] 19 [3 4 ] 19 = [9 2 ] 19 = [5] 19 [3 8 ] 19 = [5 2 ] 19 = [6] 19 [3 16 ] 19 = [6 2 ] 19 = [17] 19 [3 32 ] 19 = [17 2 ] 19 = [4] 19 [3 64 ] 19 = [4 2 ] 19 = [16] 19 [3 128 ] 19 = [16 2 ] 19 = [9] 19 [3 256 ] 19 = [9 2 ] 19 = [5] 19 [3 512 ] 19 = [5 2 ] 19 = [6] 19 So, [3 704 ] 19 = [(3 512 )(3 128 )(3 64 )(3 8 )(3 2 )(3)] 19 = [(6)(9)(16)(6)(9)(3)] 19 = [139968] 19 = [14] 19 = 14. Q 2.2.3: For a given N, about how many multiplications do you need for this technique? Q 2.2.4: [2 1030 ] 35 =? Q 2.2.5: [5 317 ] 12 =? 2.3 Inverses and Identities Def: Identity An identity is an element that changes nothing. The additive identity is zero, because x + 0 = x for any x, and the multiplicative identity is 1, because 1 x = x for any x. Def: Inverse For any given element, x, the inverse is that element that when combined with x gives you the identity. The additive inverse of x is x, since x + ( x) = 0. The multiplicative inverse of x is 1 x, since x 1 x = 1 (except for x=0). Q 2.3.1: What is the additive inverse of [x] M? Remember that the only numbers you have to work with are 0, 1,, M 1 The multiplicative inverse is easy to find in regular math: it s just the reciprocal. But in modular arithmetic there are no fractions, so something like 1/3 makes no sense. Instead, the multiplicative inverse of 3 is denoted 3 1. Even though we don t have access to fractions, the multiplicative inverse of a number often still exists! For example, [3 1 ] 10 = [7] 10 because [3 7] 10 = [21] 10 = [1] 10 = 1. Keep in mind that the inverse of something is what you need to combine it with to get the identity, which is 1. 5

So, [3 1 ] 10 = [7] 10 and [7 1 ] 10 = [3] 10. For relatively small moduli you can find the inverse x 1 by adding x to itself over and over until you get 1 (or equivalently by multiplying x by 1, then 2, then...). For example, to find [5 1 ] 11 : j = 0 1 2 3 4 5 6 7 8 9 10 11 [5 j] 11 = 0 5 10 4 9 3 8 2 7 1 6 0 So, [9 5] 11 = 1, and [5 1 ] 11 = 9. The more common name for this approach is the brute force approach. Q 2.3.2: Using the same technique as the example above, find [1 1 ] 7, [2 1 ] 7, [3 1 ] 7, [4 1 ] 7, [5 1 ] 7, and [6 1 ] 7. Q 2.3.3: Find [1 1 ] 10, [2 1 ] 10, [3 1 ] 10, [4 1 ] 10, [5 1 ] 10, [6 1 ] 10, [7 1 ] 10, [8 1 ] 10, and [9 1 ] 10. Q 2.3.4: -In the last question several of the numbers didn t have inverses. Is there a pattern behind when a number does or doesn t have an inverse? -How many times can you add x to itself mod M before the pattern of numbers repeats? -Does [14 1 ] 36 exist? Q 2.3.5: Find [1 1 ] 115. Q 2.3.6: Find [114 1 ] 115. -Find another way to write [114] 115 that would help explain the answer you got. Q 2.3.7: What is [(M 1) 1 ] M, for any M? Q 2.3.8: If 3 M, then [(M + 1) 1 ] 3M =? When you re trying to find an inverse for x mod M what you re trying to do is solve [j x] M = [1] M for j. In other words, you re trying to find j such that jx = km + 1. So, one way to find [x 1 ] M, is to solve the linear Diophantine equation, jx+km = 1, for j (k doesn t matter). Example: [13 1 ] 17 =? This is the same as solving 13j + 17k = 1, and j is the inverse we re looking for. Like any Diophantine equation, we ll use Euclid s equation. A = 17, B = 13 6

r 1 = 17 r 1 = 1A + 0B r 2 = 13 r 2 = 0A + 1B r 3 = 4 r 3 = r 1 1 r 2 r 3 = 1A 1B r 4 = 1 r 4 = r 2 3 r 3 r 4 = 3A + 4B So, 4 13 + ( 3) 17 = 1. Therefore, [13 1 ] 17 = [4] 17 Example: [5 1 ] 11 =? This is the same as solving j5 + k11 = 1. A = 11, B = 5 r 1 = 11 r 1 = 1A + 0B r 2 = 5 r 2 = 0A + 1B r 3 = 1 r 3 = r 1 2 r 2 r 3 = 1A 2B Therefore, ( 2) 5 + 11 = 1. But, in general, only numbers between 0 and M 1 are used, so [5 1 ] 11 = [ 2] 11 = [9] 11 Q 2.3.9: Find ]3 1 ] 32. Q 2.3.10: Find [53 1 ] 97. Q 2.3.11: Find [13 1 ] 52. Q 2.3.12: Find [5 1 ] 653. 2.4 The Euler totient function, ϕ Def: ϕ(n) is equal to the number of integers less than N that are coprime to N. Two numbers are coprime if their gcd is 1. ϕ(1) = 1 by definition. Example: ϕ(20) =? The prime divisors of 20 are 2 and 5. If a number isn t a multiple of 2 or 5, then it s coprime to 20. Those numbers are: 1, 3, 7, 9, 11, 13, 17, 19. That s eight numbers. ϕ(20) = 8 Q 2.4.1: Find ϕ(n) for N = 1,, 15 Q 2.4.2: It s often easier to find the number of numbers less than or equal to N that share a common divisor with N. Once you ve done that, then ϕ(n) is what s left. -What is ϕ(p), where p is prime? -What is ϕ(p k ), where p is prime? -What is ϕ(pq), where p and q are prime? 7

It s worth knowing that when gcd(a, B) = 1, ϕ(ab) = ϕ(a)ϕ(b). This allows us to calculate ϕ(n) quickly if we can factor N. For example, ϕ(15) = ϕ(3)ϕ(5) = 2 4 = 8. Q 2.4.3: Find a general formula for ϕ(n), assuming that you already know all of the factors of N. Q 2.4.4: Prove that the sum of ϕ of every divisor of N is N. For example, if N = 10, then the divisors are d = 1, 2, 5, 10 and ϕ(1) + ϕ(2) + ϕ(5) + ϕ(10) = 1 + 1 + 4 + 4 = 10. Hint: If gcd(a, b) = x, then what s gcd ( a x, b x)? 8