C-N Math 207 Discrete Math

Similar documents
C-N Math 207 Discrete Math

Mathematics of Cryptography

Chapter 5. Number Theory. 5.1 Base b representations

5: The Integers (An introduction to Number Theory)

Chapter 5: The Integers

Exercises Exercises. 2. Determine whether each of these integers is prime. a) 21. b) 29. c) 71. d) 97. e) 111. f) 143. a) 19. b) 27. c) 93.

4 Number Theory and Cryptography

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

4 Powers of an Element; Cyclic Groups

Sets. We discuss an informal (naive) set theory as needed in Computer Science. It was introduced by G. Cantor in the second half of the nineteenth

3 The fundamentals: Algorithms, the integers, and matrices

0 Sets and Induction. Sets

Modular Arithmetic Instructor: Marizza Bailey Name:

CHAPTER 6. Prime Numbers. Definition and Fundamental Results

2 Elementary number theory

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

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

MATH 2200 Final Review

Integers and Division

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

1 Overview and revision

Arithmetic and Algebra

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?

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

Notes for Math 290 using Introduction to Mathematical Proofs by Charles E. Roberts, Jr.

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

Applied Cryptography and Computer Security CSE 664 Spring 2017

NOTES ON SIMPLE NUMBER THEORY

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

Lecture 2. The Euclidean Algorithm and Numbers in Other Bases

MATH Fundamental Concepts of Algebra

Number Theory and Group Theoryfor Public-Key Cryptography

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

Proofs. Methods of Proof Divisibility Floor and Ceiling Contradiction & Contrapositive Euclidean Algorithm. Reading (Epp s textbook)

Beautiful Mathematics

MATH 361: NUMBER THEORY FOURTH LECTURE

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

CHAPTER 3. Congruences. Congruence: definitions and properties

Basic elements of number theory

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

Basic elements of number theory

4. Number Theory (Part 2)

Lecture Notes 1 Basic Concepts of Mathematics MATH 352

Number Theory Proof Portfolio

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

2k n. k=0. 3x 2 7 (mod 11) 5 4x 1 (mod 9) 2 r r +1 = r (2 r )

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

Number Theory Marathon. Mario Ynocente Castro, National University of Engineering, Peru

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?

Lecture 5: Arithmetic Modulo m, Primes and Greatest Common Divisors Lecturer: Lale Özkahya

MATH 145 Algebra, Solutions to Assignment 4

Student Responsibilities Week 8. Mat Section 3.6 Integers and Algorithms. Algorithm to Find gcd()

CSE 1400 Applied Discrete Mathematics Proofs

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

Lecture Notes. Advanced Discrete Structures COT S

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

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

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

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

Part IA Numbers and Sets

CISC-102 Fall 2017 Week 6

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

Number Theory Marathon. Mario Ynocente Castro, National University of Engineering, Peru

PROBLEMS ON CONGRUENCES AND DIVISIBILITY

Mat Week 8. Week 8. gcd() Mat Bases. Integers & Computers. Linear Combos. Week 8. Induction Proofs. Fall 2013

PRIME NUMBERS YANKI LEKILI

CS March 17, 2009

Deepening Mathematics Instruction for Secondary Teachers: Algebraic Structures

Elementary Number Theory Review. Franz Luef

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

1. multiplication is commutative and associative;

4 PRIMITIVE ROOTS Order and Primitive Roots The Index Existence of primitive roots for prime modulus...

Chapter 1 : The language of mathematics.

Part I, Number Systems. CS131 Mathematics for Computer Scientists II Note 1 INTEGERS

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

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

With Question/Answer Animations. Chapter 4

Notes on Systems of Linear Congruences

1. Consider the conditional E = p q r. Use de Morgan s laws to write simplified versions of the following : The negation of E : 5 points

Mathematics for Computer Science Exercises for Week 10

CMPUT 403: Number Theory

not to be republished NCERT REAL NUMBERS CHAPTER 1 (A) Main Concepts and Results

Definition 6.1 (p.277) A positive integer n is prime when n > 1 and the only positive divisors are 1 and n. Alternatively

MATH FINAL EXAM REVIEW HINTS

MATH 4400 SOLUTIONS TO SOME EXERCISES. 1. Chapter 1

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

cse547, math547 DISCRETE MATHEMATICS Professor Anita Wasilewska

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

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

Introduction to Abstract Mathematics

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

Summary Slides for MATH 342 June 25, 2018

Clock Arithmetic and Euclid s Algorithm

Objective Type Questions

Numbers, Groups and Cryptography. Gordan Savin

COMP9020 Lecture 3 Session 2, 2014 Sets, Functions, and Sequences. Revision: 1.3

The Chinese Remainder Theorem

Number theory lectures

The Integers and Beyond

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

Transcription:

C-N Math 207 - Massey, 1 / 70 C-N Math 207 Discrete Math Kenneth Massey September 16, 2011

Question C-N Math 207 - Massey, 2 / 70 Introduction What is the smallest positive number?

Sets C-N Math 207 - Massey, 3 / 70 Introduction a set S is a collection of objects (members, elements) S = {VT, UNC, GT, Mia, UVA, Duke} the cardinality (size) of S is written as S S is finite if S <, and infinite if S = empty / null set = { }, = 0 x is an element of S is denoted by x S

Numbers C-N Math 207 - Massey, 4 / 70 Introduction Abstract notions of quantity, position, or size. natural numbers N = {0, 1, 2, 3, } (use N + to omit zero) integers Z = {, 2, 1, 0, 1, 2, 3, } set-builder notation: members such that conditions rational numbers Q = { n d n, d Z, d 0} real numbers R is the continuum of all points on number line including irrationals e.g. 2, π

Set Examples C-N Math 207 - Massey, 5 / 70 Introduction 1. S = {x Z x 5 2} 2. S = {1, 1 2, 1 4, 1 8, } 3. S = {(x, y) R 2 x 2 + y 2 1} 4. S = {ticker symbols of S&P 500 members}

Discrete vs Continuous C-N Math 207 - Massey, 6 / 70 Introduction A set is discrete if its members can be listed (enumerated) so that each has a next (successor), with nothing in-between all finite sets are discrete (loop) examples: 1. digital computers 2. money (Office Space rounding) 3. siblings ( 1 2 allowed) 4. water discrete, but practically continuous 5. quantum physics 6. movie frames vs real time? 7. Z vs R, Q?

Existence and Uniqueness C-N Math 207 - Massey, 7 / 70 Introduction there exists is denoted by x Z x 2 = 9! means there exists a unique! x R 3x + 4 = 10 slash through a symbol means not x Q x 2 = 2

If-Then Statements C-N Math 207 - Massey, 8 / 70 Introduction If (condition) then (conclusion) The conclusion must be true whenever the condition is true. Any exception (counter-example) means the if-then statement is false. If c Z, then x R x 2 + 6x = c

Function C-N Math 207 - Massey, 9 / 70 Introduction f : A B is a function that pairs each member of set A with a unique member of set B. y = f (x ) where x A and y B the set A is called the domain the set B is called the codomain {b B a A with f (a) = b} is called the range or image of f

Function Examples C-N Math 207 - Massey, 10 / 70 Introduction 1. f : R R defined by y = f (x ) = x 2 2. f : Z N defined by y = f (x ) = x 2 3. f : N N defined by y = f (n) = n 4. f : N + Q defined by f (n) = n+1 n Which are onto (range equals codomain)? Which are one-to-one (no y value hit twice)?

Invertible Function C-N Math 207 - Massey, 11 / 70 Introduction f is said to be invertible if each y in B is mapped to exactly once f 1 : B A is a function that reverses f To find the inverse, solve for x. x = f 1 (y) the composition of a function and its inverse is the identity function f 1 f = I f 1 (f (x )) = x and f (f 1 (y) = y

Sequence C-N Math 207 - Massey, 12 / 70 Introduction A sequence is a function whose domain is some subset of Z (often N). an ordered indexed list, f (k) = f k geometric sequence a k = r k for some r R harmonic sequence { } 1 k k=1

C-N Math 207 - Massey, 13 / 70 Sum Notation Capital Greek sigma Σ indicates the sum of indexed terms, e.g. 6 k 2 = 3 2 + 4 2 + 5 3 + 6 2 = 86 k=3 k=1 a n = Introduction 1 10 k =.1 +.01 +.001 + =.11111 = 1 9 n k = k=1 n(n + 1) 2

Product Notation C-N Math 207 - Massey, 14 / 70 Introduction Capital Greek pi Π indicates the product of indexed terms, e.g. 4 k=1 k + 1 k = (2/1)(3/2)(4/3)(5/4) = 5

Factorials C-N Math 207 - Massey, 15 / 70 Introduction n factorial is defined for n N by n! = { n k=1 k n 1 1 n = 0 the sequence of factorials is 1, 1, 2, 6, 24, 120, n! = n (n 1)!

C-N Math 207 - Massey, 16 / 70 Z is discrete, but infinite Subsets of Z can be used to label other discrete sets. Arithmetic operations: addition (+) and multiplication ( ) Basic properties: closed, commutative, associative, distributive, identities, inverses, ordered Number theory is the branch of mathematics that studies the properties of Z.

Division Algorithm C-N Math 207 - Massey, 17 / 70 Note that 17 3 = 5 + 2 3 can be written as 17 = 3 5 + 2 Division algorithm: let a, b Z, with b 0, then! q, r Z such that a = bq + r, 0 r < b q is called the quotient, and r the remainder. example: a = ±73, b = 11

Place Value C-N Math 207 - Massey, 18 / 70 Ways to represent natural numbers: tally/tic marks, Egyptian, Roman numeral, place value (brilliant!). We are familiar with base 10, but other societies have used e.g. base 12 or 60. Computers use binary (base 2) octal (base 8), [hexadecimal] (base 16)

Place Value Each x N can be uniquely represented in base b as a linear combination of powers of b, with each coefficient (digit) between 0 and b 1. C-N Math 207 - Massey, 19 / 70 d 1 x = (D d 1 D 2 D 1 D 0 ) b = D k b k k=0 (75) 10 = 7 10 1 + 5 10 0 (113) 8 = 1 8 2 + 1 8 1 + 3 8 0 (300) 5 = 3 5 2 (1001011) 2 = 2 6 + 2 3 + 2 1 + 2 0 (4B) 16 = 4 16 1 + 11 16 0

Place Value C-N Math 207 - Massey, 20 / 70 Write (146) 10 in base 3 using the division algorithm. 146 = 3 48 + 2 = 3 (3 16 + 0) + 2 = 3 (3 (3 5 + 1) + 0) + 2 = 3 (3 (3 (3 1 + 2) + 1) + 0) + 2 So (146) 10 = (12102) 3.

Place Value C-N Math 207 - Massey, 21 / 70 There are 10 types of people in the world: those that understand binary, and those that don t. 1. Coach Sparks decides to use hexadecimal for the football team s jersey numbers. If a jersey reads AC, find the decimal and binary equivalents. 2. How many points did C-N win by if the scoreboard reads 53 32 in base 7?

Place Value C-N Math 207 - Massey, 22 / 70 Arithmetic algorithms work the same way in other bases. 1. (234) 5 + (312) 5 2. (175) 8 (6) 8 3. (11010) 2 (1011) 2

Divides C-N Math 207 - Massey, 23 / 70 Definition: Let a, b Z. Then b divides a, if and only if (iff) there exists q Z such that a = bq. in the division algorithm, r = 0 Equivalent statements: notation: b a b divides (evenly into) a a is divisible by b b is a factor/divisor of a

Generally True? C-N Math 207 - Massey, 24 / 70 1. n 0 2. 0 n 3. n 1 4. 1 n 5. n n 6. n n 2 7. (a + b) (a 2 b 2 )

Your First Proof C-N Math 207 - Massey, 25 / 70 Theorem: If a b and b c, then a c (divisibility is transitive) Illustration: 4 12 and 12 72, therefore 4 72. Proof: Suppose a b and b c. By definition, b = aq 1 and c = bq 2. Then by substitution, c = bq 2 = (aq 1 )q 2 = a(q 1 q 2 ). Therefore a c.

Direct If-Then Proofs C-N Math 207 - Massey, 26 / 70 1. Understand what you are proving. Work an example; believe it is true. 2. Scratch work: what do you know? (the if part) what do you need to show? (the then part) use definitions to translate symbols/terminology deduce the desired result using algebra, substitution, tricks, previous theorems, etc 3. Rewrite your proof neatly. State the theorem. Prove the theorem, clearly justifying each step as you move from assumptions to the conclusion.

C-N Math 207 - Massey, 27 / 70 Theorem: Suppose a, b N. If a b and b a, then a = b. Proof:

Even and Odd C-N Math 207 - Massey, 28 / 70 Definitions: n Z is even iff q Z n = 2q n Z is odd iff q Z n = 2q + 1 Prove that 1. if n is odd, then n + 5 is even. 2. if n is odd, then n 2 is odd.

Modulo C-N Math 207 - Massey, 29 / 70 As in the division algorithm, let a = bq + r. Then a modulo b is the remainder r. notation: a (mod b) = r b a iff a (mod b) = 0 odd if a (mod 2) = 1 List the possible values of a (mod 5).

Congruence C-N Math 207 - Massey, 30 / 70 a and b are congruent (aliases) mod n a b (mod n) Equivalent definitions: n (a b) a (mod n) = b (mod n) (a b) (mod n) = 0 a b = qn for some q Z

Equivalence C-N Math 207 - Massey, 31 / 70 Congruence is an equivalence relation: 1. reflexive a a (mod n) 2. symmetric if a b (mod n) then b a (mod n) 3. transitive if a b (mod n) and b c (mod n) then a c (mod n)

(mod n) C-N Math 207 - Massey, 32 / 70 The equivalence class of a (mod n) is the set of all of a s aliases. [a] n = {b Z a b (mod n)} Z n is the set of all equivalence classes (mod n) Z n = {0, 1, 2, 3, n 1} Z mod n puts each integer into exactly one class loop around like a clock

Proof of Transitivity C-N Math 207 - Massey, 33 / 70 Theorem: if a b (mod n) and b c (mod n) then a c (mod n) Proof: Assume that a b (mod n). Then by definition a b = nq 1 for some q 1 Z. Similarly b c = nq 2 for some q 2 Z. (therefore) a c = (a b)+(b c) = nq 1 +nq 2 = n(q 1 +q 2 ) and hence by definition n (a c) and a c (mod n).

Algrebra of Congruence Theorem: if a b and c d, then a + c b + d and ac bd. Proof: By assumption, and the definition of congruence, a b = q 1 n and c d = q 2 n. Therefore, C-N Math 207 - Massey, 34 / 70 (a + c) (b + d) = (a b) + (c d) = q 1 n + q 2 n = (q 1 + q 2 )n ac bd = (b + q 1 n)c b(c q 2 n) = (q 1 c + q 2 b)n Thus by definition, a + c b + d and ac bd.

Z n Algebra C-N Math 207 - Massey, 35 / 70 Hence we may develop algebra of + and on Z n. See the Affine Cipher Project. addition / [multiplication tables] inverses solving equations

Problems C-N Math 207 - Massey, 36 / 70 1. Compute 7 5 (mod 11), reducing as you go. 2. What day of the week will it be 10000 days from now? 3. Solve 4(6x 5) 5 (mod 7).

Affine Cipher C-N Math 207 - Massey, 37 / 70 The affine cipher transforms each character in an alphabet by the formula: y = f (x ) = (ax + b) (mod n) Experiment with the [web app]. Using the alphabet (space, A-Z), decrypt VWBTU if y = 5x + 2 (mod 27).

Invertibility C-N Math 207 - Massey, 38 / 70 If n = 27, a = 3, and b = 5 then J (letter 10) gets tranformed to H, but so does A To be decipherable, a cipher function must be invertible (reversible). Each character must be mapped to exactly once. If n = 27, what values of a make the affine cipher an invertible function? What if n = 28?

Affine De-Cipher C-N Math 207 - Massey, 39 / 70 if y = f (x ) = ax + b then x = f 1 (y) = a 1 (y b) y = ax + b is invertible iff a 1 exists find 7 1 (mod 27) by writing {7k (mod 27)} 7 1 (mod 28) DNE inverses come in pairs (some may be their own inverse) hypothesize about when a 1 (mod n) exists

A Weird Function C-N Math 207 - Massey, 40 / 70 Let δ : N + N be defined by δ(n) = {q N q n} Describe the function in words. Compute δ(21).

Prime Numbers C-N Math 207 - Massey, 41 / 70 Let n > 1 be a natural number. Definition: n is prime if its only natural number divisors are 1 and n itself. n is prime iff δ(n) =. If n is not prime, then it is composite. If n is composite, then it has a prime factor which is n. Sieve of Eratosthenes

Fundamental Theorem of Arithmetic C-N Math 207 - Massey, 42 / 70 Fundamental Theorem of Arithmetic: each n > 1 can be written uniquely (up to ordering) as the product of prime factors n = p α i i e.g. the prime factorization of 21560 is 21560 = 2 3 5 7 2 11

Prime Number Theorem C-N Math 207 - Massey, 43 / 70 Let π(n) be the number of primes p n. π(n) n ln(n) This estimate was proved to be asymptotic in 1896. lim n π(n) n/ ln(n) = 1

Greatest Common Divisor C-N Math 207 - Massey, 44 / 70 Define the greatest common divisor of a, b Z to be the largest integer that is a divisor of both a and b. e.g. gcd(36, 84) = 12 (can use prime factors) If a 0, then gcd(a, 0) = a. a and b are relatively prime (coprime) if gcd(a, b) = 1

Least Common Multiple C-N Math 207 - Massey, 45 / 70 Define the least common multiple of a, b Z to be the smallest natural number that is a multiple of both a and b. e.g. lcm(14, 35) = 70 (can use prime factors) If l = lcm(a, b) then a l and b l Define lcm(a, 0) = 0 as a special case.

GCD and LCM C-N Math 207 - Massey, 46 / 70 gcd and lcm are commutative functions Use prime factors to find gcd(24, 30) and lcm(24, 30). Convince yourself that gcd(a, b) lcm(a, b) = ab.

Proving or Disproving C-N Math 207 - Massey, 47 / 70 Consider a general if-then statement. To be true, it must hold for any condition that satisfies the if part. No exceptions. You can t prove the statement by cherry-picking examples that work. You can disprove the statement by finding one counter-example: a case where the if part is true, but the then part is false.

Disprove C-N Math 207 - Massey, 48 / 70 Find a counter-example to the following: 1. if n > 0 then 2 2n + 1 is prime 2 25 + 1 = 4294967297 = (641)(6700417) 2. if c (ab) then either c a or c b 3. gcd(ma, nb) = gcd(m, n) gcd(a, b)

Prove C-N Math 207 - Massey, 49 / 70 1. If x 3 (mod 8) then x 2 9 (mod 16). 2. The product of two consecutive integers is even. (rewrite as if/then) 3. If n is odd, then 8 (n 2 1). 4. If c a and c b, then for any m, n Z, c (ma + nb). 5. If n N, then gcd(n, n + 1) = 1.

Prove or disprove C-N Math 207 - Massey, 50 / 70 1. If p is prime, then p + 7 is composite. 2. If n > 0, then 3 n + 2 is prime. 3. If a b (mod n) then a 2 b 2 (mod n 2 ) 4. If a b (mod n) then a 2 b 2 (mod n)

Mathematical Statements C-N Math 207 - Massey, 51 / 70 conjecture: believed to be true, but unproven lemma: a precursor to a more noteworthy theorem theorem: has been proved corollary: follows as a special case of a theorem

Fun Fact C-N Math 207 - Massey, 52 / 70 (Liouville) Pick any n N + and write down its divisors, e.g. if n = 50 then {1, 2, 5, 10, 25, 50}. Then count how many divisors each divisor has. C = {1, 2, 2, 4, 3, 6}. Then ( C x )2 = C x 3. (1+2+2+4+3+6) 2 = 1+8+8+64+27+216 Proof is beyond the scope of this class.

E.A. Lemma 1 C-N Math 207 - Massey, 53 / 70 Lemma: For any k Z, x divides both a and b if and only if (iff) x divides both a + kb and b Proof: Suppose x a and x b. Then a = xq 1 and b = xq 2. Therefore a + kb = x (q 1 + kq 2 ), and so x (a + kb). Now suppose x (a + kb) and x b. Then a + kb = xq 1 and b = xq 2. Therefore a = xq 1 kb = x (q 1 kq 2 ), and so x a.

E.A. Lemma 2 C-N Math 207 - Massey, 54 / 70 Lemma: For any k Z, gcd(a, b) = gcd(b, a + kb) Proof: By the previous lemma, the set of common divisors of a and b is identical to the set of common divisors of a + kb and b. Therefore the GCD s must be the same.

Euclidean Algorithm C-N Math 207 - Massey, 55 / 70 Euclidean Algorithm Theorem: gcd(a, b) = gcd(b, a (mod b)) Proof: Use the division algorithm to write a = bq + r, where r = a (mod b). Then r = a bq. Taking k = q, the previous lemma says that gcd(a, b) = gcd(b, a bq) = gcd(b, r)

C-N Math 207 - Massey, 56 / 70 E.A. Example The Euclidean algorithm repeatedly uses the previous theorem to find the GCD of two numbers. gcd(952, 210) = gcd(210, 112) = gcd(112, 98) = gcd(98, 14) = gcd(14, 0) = 14

E.A. Exercises C-N Math 207 - Massey, 57 / 70 1. Use the EA to find gcd(12540, 2002), then find the lcm. 2. Show that 495 and 392 are relatively prime. 3. True or false? gcd(a, b, c) = gcd(gcd(a, b), c) 4. Draw a line from (0, 0) to (a, b) in the Cartesian plane. How many integer lattice points does it cross?

C-N Math 207 - Massey, 58 / 70 GCD as a Linear Combination Back-substitution allows us to write the gcd as a linear combination of the two arguments, that is gcd(a, b) = c 1 a + c 2 b. 952 = (210)(4) + 112 210 = (112)(1) + 98 112 = (98)(1) + 14 98 = (14)(7) + 0 112 = 952(1) + (210)( 4) 98 = (952)( 1) + (210)(5) 14 = (952)(2) + (210)( 9)

GCD as a Linear Combination C-N Math 207 - Massey, 59 / 70 Theorem a and b are relatively prime iff 1 can be written as a linear combination of a and b. Proof First suppose a and b are relatively prime. Then gcd(a, b) = 1, and the EA with back-substitution allows us to write c 1 a + c 2 b = gcd(a, b) = 1. Now suppose c 1 a + c 2 b = 1, and suppose x is a divisor of both a and b. Say a = xq 1 and b = xq 2. Then x (c 1 q 1 + c 2 q 2 ) = 1, and since everything is an integer, it must be that x = 1. Therefore gcd(a, b) = 1.

C-N Math 207 - Massey, 60 / 70 Inverses in Z n Theorem If gcd(a, n) = 1, then a has an inverse in Z n. Proof Since gcd(a, n) = 1, we can write c 1 a + c 2 n = 1. Therefore c 1 a 1 (mod n), and c 1 is the candidate inverse. (existence) To be the inverse, c 1 must be the unique solution to ax 1 in Z n. If ax 1 then ac 1 ax 0, and therefore c 1 a(c 1 x ) 0. But since c 1 a 1, we get c 1 x 0 or x c 1. (uniqueness) a 1 = c 1

C-N Math 207 - Massey, 61 / 70 Inverses in Z n Theorem The converse is also true: if a has in inverse in Z n, then gcd(a, n) = 1. Proof Suppose ab 1 (mod n), so that ab = 1 + kn. Let d be a divisor of both a and n, so that a = dq 1 and n = dq 2. Then dq 1 b = 1 + kdq 2, and d(q 1 b kq 2 ) = 1. The only integer possibility is d = ±1.

C-N Math 207 - Massey, 62 / 70 Finding an inverse in Z n 1. Show that a = 28 and n = 135 are relatively prime, and write 1 as a linear combination of a and n. 2. Find 28 1 (mod 135). 3. Find 4 1 in Z 27 (easy by inspection) 4. Find 8 1 in Z 27 (use EA) 5. Solve 10(x 7) = 6 + 2x in Z 27

Affine Cipher Decryption C-N Math 207 - Massey, 63 / 70 Recall the affine cipher function and its inverse: y = ax + b (mod n) x = a 1 (y b) We now know that a 1 exists iff gcd(a, n) = 1. In general, use the EA to write c 1 a + c 2 n = 1, and then a 1 = c 1. If n = 27, a = 2, and b = 5, then y = 2x + 5 (mod 27) x = 14(y 5).

Pirate Treasure C-N Math 207 - Massey, 64 / 70 CRT A band of ten pirates captured a treasure chest full of gold coins. When they attempted to divide the coins evenly, 3 were left over. A fight ensued and one pirate was killed. Again they attempted to divide the coins, but now there were 8 left over. This time two pirates were killed fighting over the extras. On the third try, the coins divided evenly. How many coins were in the chest?

Pirate Treasure C-N Math 207 - Massey, 65 / 70 CRT Solve the system of congruences: x 3 (mod 10) x 8 (mod 9) x 0 (mod 7)

Chinese Remainder Theorem C-N Math 207 - Massey, 66 / 70 CRT Chinese Remainder Theorem: if m 1 and m 2 are relatively prime, then x r 1 (mod m 1 ) x r 2 (mod m 2 ) has a unique solution (mod m 1 m 2 ). This theorem can be extended to 3 or more congruences by induction.

CRT Algorithm C-N Math 207 - Massey, 67 / 70 CRT Idea: absorb each congruence sequentially: x = 3 + 10n 3 + 10n 8 (mod 9) 1n 5 (mod 9) n 1 1 5 (mod 9) n = 5 x = 53 (mod 90) 53 + 90n 0 (mod 7) 4 + 6n 0 (mod 7) 6n 3 (mod 7) n = 6 1 3 (mod 7) n = 4 x = 413 (mod 630)

Football Scores C-N Math 207 - Massey, 68 / 70 CRT Find all scores less than 100 that satisfy: x 1 (mod 2) x 2 (mod 3) x 3 (mod 7)

CRT Conditions This system has solutions C-N Math 207 - Massey, 69 / 70 CRT x 3 (mod 4) x 5 (mod 6) but this one is inconsistent, and has no solution. x 2 (mod 4) x 5 (mod 6)

Eggs C-N Math 207 - Massey, 70 / 70 CRT An old woman goes to market and a horse steps on her basket and crushes the eggs. The rider offers to pay for the damages and asks her how many eggs she had brought. She does not remember the exact number, but when she had taken them out two at a time, there was one egg left. The same happened when she picked them out three, four, five, and six at a time, but when she took them seven at a time they came out even. What is the smallest number of eggs she could have had?