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

Similar documents
NOTES ON SIMPLE NUMBER THEORY

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

1 Overview and revision

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

Notes on Systems of Linear Congruences

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?

Chapter 2. Divisibility. 2.1 Common Divisors

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?

Commutative Rings and Fields

Number Theory Basics Z = {..., 2, 1, 0, 1, 2,...} For, b Z, we say that divides b if z = b for some. Notation: b Fact: for all, b, c Z:

Number Theory Proof Portfolio

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

Chapter 5. Number Theory. 5.1 Base b representations

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

Math 511, Algebraic Systems, Fall 2017 July 20, 2017 Edition. Todd Cochrane

The following is an informal description of Euclid s algorithm for finding the greatest common divisor of a pair of numbers:

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

4 Number Theory and Cryptography

Mathematics of Cryptography

Modular Arithmetic Instructor: Marizza Bailey Name:

Computations/Applications

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

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

HOMEWORK 4 SOLUTIONS TO SELECTED PROBLEMS

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

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

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

Fall 2017 Test II review problems

CS March 17, 2009

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

3 The fundamentals: Algorithms, the integers, and matrices

2 Elementary number theory

The Fundamental Theorem of Arithmetic

Discrete Structures Lecture Solving Congruences. mathematician of the eighteenth century). Also, the equation gggggg(aa, bb) =

MTH 346: The Chinese Remainder Theorem

Number theory (Chapter 4)

CSE20: Discrete Mathematics

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

INTEGERS. In this section we aim to show the following: Goal. Every natural number can be written uniquely as a product of primes.

Modular Arithmetic and Elementary Algebra

Homework #2 solutions Due: June 15, 2012

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

Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry. Spring 2006

Rings and modular arithmetic

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

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

4.4 Solving Congruences using Inverses

Lecture 7 Number Theory Euiseong Seo

Divisibility. Chapter Divisors and Residues

THE GAUSSIAN INTEGERS

The Chinese Remainder Theorem

4. Congruence Classes

8 Primes and Modular Arithmetic

7. Prime Numbers Part VI of PJE

Divisibility in the Fibonacci Numbers. Stefan Erickson Colorado College January 27, 2006

Number Theory and Divisibility

Basic elements of number theory

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

Basic elements of number theory

7.2 Applications of Euler s and Fermat s Theorem.

Number Theory A focused introduction

Chapter 1 A Survey of Divisibility 14

Finite Fields: An introduction through exercises Jonathan Buss Spring 2014

Beautiful Mathematics

4 Powers of an Element; Cyclic Groups

18 Divisibility. and 0 r < d. Lemma Let n,d Z with d 0. If n = qd+r = q d+r with 0 r,r < d, then q = q and r = r.

Integers and Division

A Readable Introduction to Real Mathematics

Discrete Mathematics and Probability Theory Fall 2013 Vazirani Note 3

Fermat's Little Theorem

Elementary Properties of the Integers

Discrete Mathematics and Probability Theory Summer 2014 James Cook Note 5

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?

Elementary Number Theory. Franz Luef

Rings If R is a commutative ring, a zero divisor is a nonzero element x such that xy = 0 for some nonzero element y R.

Wilson s Theorem and Fermat s Little Theorem

download instant at

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

CHAPTER 3. Congruences. Congruence: definitions and properties

The Euclidean Algorithm and Multiplicative Inverses

Arithmetic and Algebra

Algorithmic number theory. Questions/Complaints About Homework? The division algorithm. Division

MATH FINAL EXAM REVIEW HINTS

2.2 Inverses and GCDs

1. multiplication is commutative and associative;

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?

Clock Arithmetic and Euclid s Algorithm

Number Theory and Group Theoryfor Public-Key Cryptography

Summary: Divisibility and Factorization

Math.3336: Discrete Mathematics. Primes and Greatest Common Divisors

Number Theory Notes Spring 2011

Numbers. 2.1 Integers. P(n) = n(n 4 5n 2 + 4) = n(n 2 1)(n 2 4) = (n 2)(n 1)n(n + 1)(n + 2); 120 =

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

AN ALGEBRAIC PROOF OF RSA ENCRYPTION AND DECRYPTION

Complex Numbers. Rich Schwartz. September 25, 2014

Further linear algebra. Chapter II. Polynomials.

Today. Polynomials. Secret Sharing.

2. THE EUCLIDEAN ALGORITHM More ring essentials

CSE 20 DISCRETE MATH. Winter

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

Transcription:

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

Scheme version of the algorithm! for finding the GCD (define (gcd a b)! (if!(= b 0)!!!!a!!!!(gcd b (remainder a b))))!!

gcd (812, 17) = gcd(17, 13) = gcd(13, 4) = gcd (4, 1) = gcd (1, 0) = 1 An example:

Not only is this idea super-fast, but it s also useful: (18, 7) = (7, 4) = (4, 3) = (3, 1) = (1, 0) = 1 18 = (2 * 7) + 4 7 = (1* 4) + 3 4 = (1 * 3) + 1 Now, unwind those statements: 1 = 4 (1 * 3) = 4 - (1 * (7 (1 * 4))) = 4 (7 4) = (2 * 4) - 7 = ((2 * (18 (2 * 7))) 7 = (2 * 18) (5 * 7)

The Structure of Divisors Let s try to break down a number s divisors as far as we can: 84 = 2 * 42 = 2 * 2 * 21 = 2 * 2 * 3 * 7 We can t go any further than this, since we have only prime factors.

The Fundamental Theorem of Arithmetic Every number n has a unique factorization into primes.

A Lemma Suppose d (ab) and gcd(d,a) = 1 In prose: d goes into the product of a and b, but d and a are relatively prime. Then d b

Let s prove the lemma. Since d ab We can write: ab = dq And since gcd(d, a) = 1 We can find x and y such that: dx + ay = 1 So: dbx + aby = b dbx + dqy = b d(bx + qy) = b

Lemma 2 (a corollary to Lemma 1) We now know that if d (ab) and gcd(d,a) = 1, then d b. Suppose d is a prime number (let s call it p for prime). Then if p (ab), we know that either p a or p b. Proof: Suppose p doesn t go into a. Then by the definition of greatest common divisor (and the definition of a prime number ), gcd(p,a) = 1. Which means, from our previous lemma, that p b.

More generally, we have the following: p q 1 q 2 q 3 q n means that p must go into at least one factor in the product.

Now we re ready to prove the Fundamental Theorem of Arithmetic First we show that every number can be factored into primes. (We ll leave uniqueness for the next step.) Step 1. We know that 2 can be factored into primes (i.e., 2 itself). Step 2. Suppose that all numbers from 2 n can be factored into primes. Consider n+1. If it s prime, we re done. Step 3. Suppose it isn t prime. Then it must have some factor q. So qx = (n+1). But we know that both q and x are smaller than n+1, so they can be factored into primes. A note: this technique (step 2) is called strong induction.

The factorization is unique (proof by contradiction). Suppose the factorization weren t unique. Let m be the smallest number with two distinct prime factorizations, with factors ordered low to high: p 1 p 2 p 3..p j = m = q 1 q 2 q 3 q k If p 1 is equal to q 1, then we can divide both factorizations by that number, and we have a smaller value with two distinct factorizations (contrary to our assumption). So choose the smaller of p 1, q 1 : let s say it s p 1. Then by our earlier lemma 2, p 1 must go into one of the q factors, contrary to our assumption that they re all prime! Either way, we have a contradiction.

Okay, now we re ready to play with factorizations: n = 2 e1 * 3 e2 * 5 e3 * 7 e4 *

Since we can break down every positive number into primes, we can answer a question like this: What s the smallest number divisible by 1, 2, 3, 10? Let s take a more specific case: suppose you have several prime numbers, like (say) 3, 5, and 7. What s the smallest number divisible by these three primes?

Let s go back to modular arithmetic for a moment Recall our discussion of the idea a mod n : this is just the remainder (from 0 to n-1) when a is divided by n. We saw that when two numbers, a and b, have the same remainder when divided by n, we can write: a n b

We can do addition, subtraction, and multiplication in modular Suppose: arithmetic a n b and c n d Then: (a + c) n (b + d) and (ac) n (bd)

We can t (in general) do division: Suppose (6*a) 20 18 Can we divide both sides of this expression by 6? Nope: a could be 3, or 13. So there isn t a unique answer to 18 divided by 6 mod 20.

Remainder mod 3 5 7 0 1 2 3 4 5 6 7 8 9 10 11 12 13

The Chinese Remainder Theorem (informal) Take a set of distinct primes, p 1, p 2, p n Now consider all the numbers from 0 to the product p 1 * p 2 * p n. Each of these numbers will have a distinct fingerprint mod each of the prime values. In other words, any number k (up to the product of all the primes) can be recognized by its set of remainders.

If you have a two-prime base, it s easy to invert the code What number has the code 2, 4 mod 3 and 7 respectively? Here s the recipe: remember Bezout s theorem for 3 and 7: 3x + 7y = 1 for some x and y

Inverting the code 3x + 7y = 1 x = -2, y = 1 So 3*(-2) + 7*1 = 1 Now we want to invert the code for (2, 4). We reverse the code and insert those numbers into our Bezout expression: 3 * (-2) * 4 + 7 * 1* 2 = 14-24 = -10 = 11 mod 21

Why does this work? Suppose we have two distinct primes, p 1 and p 2. We find x and y so that: p 1 x + p 2 y = 1 Now, suppose we want to know what value of N has remainder a 1 for p 1 and a 2 for p 2.

Let s show that: p 1 a 2 x + p 2 a 1 y = N has the right properties. What is N mod p 1? The first term of the sum above drops out (it looks like 0 mod p 1 ). So we get: N mod p 1 = (a 1 p 2 y) mod p 1 = a 1 (1 p 1 x) mod p 1 = a 1 mod p 1 as desired!

Using the Chinese Remainder Theorem Let s take 10 primes: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29. Now we can represent (with a code of 10 small numbers) all the positive numbers up to 6469693229 We can do things like (say) multiply in parallel

Modular Multiplication: Mod 6 0 1 2 3 4 5 0 0 0 0 0 0 0 1 0 1 2 3 4 5 2 0 2 4 0 2 4 3 0 3 0 3 0 3 4 0 4 2 0 4 2 5 0 5 4 3 2 1

Mod 7 Multiplication 0 1 2 3 4 5 6 0 0 0 0 0 0 0 0 1 0 1 2 3 4 5 6 2 0 2 4 6 1 3 5 3 0 3 6 2 5 1 4 4 0 4 1 5 2 6 3 5 0 5 3 1 6 4 2 6 0 6 5 4 3 2 1

Patterns There are 0 s in the interior of the 6 table, but not the 7 table. (Why?) Each row of the 7 s table includes each of the values 0-6. (Why?) In the 7 s table, the 1 s row counts up (naturally); the 6 s row counts down (why?)