Computing Quotient and Remainder. Prime Numbers. Factoring by Trial Division. The Fundamental Theorem of Arithmetic

Similar documents
4.4 Solving Congruences using Inverses

The Chinese Remainder Theorem

MATH 433 Applied Algebra Lecture 4: Modular arithmetic (continued). 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?

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?

Primitive Roots and Discrete Logarithms

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

CPSC 467b: Cryptography and Computer Security

Chapter 3 Basic Number Theory

Wilson s Theorem and Fermat s Little Theorem

3 The fundamentals: Algorithms, the integers, and matrices

Exam 2 Solutions. In class questions

Chapter 5. Modular arithmetic. 5.1 The modular ring

1 Divisibility Basic facts about divisibility The Division Algorithm... 3

A field F is a set of numbers that includes the two numbers 0 and 1 and satisfies the properties:

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

4. Congruence Classes

4 Number Theory and Cryptography

Congruence of Integers

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 Notes Spring 2011

Number Theory and Group Theoryfor Public-Key Cryptography

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

Euclidean Domains. Kevin James

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

Coding Theory ( Mathematical Background I)

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 = ,

1. multiplication is commutative and associative;

1. Factorization Divisibility in Z.

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

2. THE EUCLIDEAN ALGORITHM More ring essentials

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

1 Overview and revision

Basic elements of number theory

Basic elements of number theory

Elementary Number Theory Review. Franz Luef

Homework #2 solutions Due: June 15, 2012

CHAPTER 3. Congruences. Congruence: definitions and properties

Number Theory A focused introduction

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

EULER S THEOREM KEITH CONRAD

Lecture 4: Number theory

CS March 17, 2009

ax b mod m. has a solution if and only if d b. In this case, there is one solution, call it x 0, to the equation and there are d solutions x m d

Math 5330 Spring Notes Congruences

Summary Slides for MATH 342 June 25, 2018

Rings and modular arithmetic

Understand the formal definitions of quotient and remainder.

CPSC 467: Cryptography and Computer Security

Contents. 4 Arithmetic and Unique Factorization in Integral Domains. 4.1 Euclidean Domains and Principal Ideal Domains

Chapter 1 : The language of mathematics.

MATH 361: NUMBER THEORY FOURTH LECTURE

Math 109 HW 9 Solutions

3.2 Solving linear congruences. v3

44.(ii) In this case we have that (12, 38) = 2 which does not divide 5 and so there are no solutions.

3.7 Non-linear Diophantine Equations

Intermediate Math Circles February 29, 2012 Linear Diophantine Equations I

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

LECTURE NOTES IN CRYPTOGRAPHY

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

MATH 4400 SOLUTIONS TO SOME EXERCISES. 1. Chapter 1

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

Number Theory. Modular Arithmetic

1. (a) q = 4, r = 1. (b) q = 0, r = 0. (c) q = 5, r = (a) q = 9, r = 3. (b) q = 15, r = 17. (c) q = 117, r = 11.

CIS 6930/4930 Computer and Network Security. Topic 5.1 Basic Number Theory -- Foundation of Public Key Cryptography

7. Prime Numbers Part VI of PJE

Integers and Division

CHAPTER 6. Prime Numbers. Definition and Fundamental Results

Outline. Some Review: Divisors. Common Divisors. Primes and Factors. b divides a (or b is a divisor of a) if a = mb for some m

Outline. AIT 682: Network and Systems Security. GCD and Euclid s Algorithm Modulo Arithmetic Modular Exponentiation Discrete Logarithms

Ch 4.2 Divisibility Properties

Course MA2C02, Hilary Term 2013 Section 9: Introduction to Number Theory and Cryptography

A Guide to Arithmetic

Numbers. Çetin Kaya Koç Winter / 18

Course 2316 Sample Paper 1

Chuck Garner, Ph.D. May 25, 2009 / Georgia ARML Practice

1. (a) q = 4, r = 1. (b) q = 0, r = 0. (c) q = 5, r = (a) q = 9, r = 3. (b) q = 15, r = 17. (c) q = 117, r = 11.

cse 311: foundations of computing Fall 2015 Lecture 11: Modular arithmetic and applications

CSC 474 Network Security. Outline. GCD and Euclid s Algorithm. GCD and Euclid s Algorithm Modulo Arithmetic Modular Exponentiation Discrete Logarithms

Computations/Applications

Course 2BA1: Trinity 2006 Section 9: Introduction to Number Theory and Cryptography

Chapter 8. Introduction to Number Theory

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

CPSC 467b: Cryptography and Computer Security

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?

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

Elementary factoring algorithms

Elementary Number Theory. Franz Luef

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

PMA225 Practice Exam questions and solutions Victor P. Snaith

Chapter 9 Mathematics of Cryptography Part III: Primes and Related Congruence Equations

Ma/CS 6a Class 2: Congruences

Elementary Number Theory MARUCO. Summer, 2018

10 Problem 1. The following assertions may be true or false, depending on the choice of the integers a, b 0. a "

Discrete valuation rings. Suppose F is a field. A discrete valuation on F is a function v : F {0} Z such that:

Eighth Homework Solutions

Number theory (Chapter 4)

Groups, Rings, and Finite Fields. Andreas Klappenecker. September 12, 2002

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

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

Transcription:

A Crash Course in Elementary Number Theory L. Felipe Martins Department of Mathematics Cleveland State University l.martins@csuohio.edu Work licensed under a Creative Commons License available at http://creativecommons.org/licenses/by-nc-sa/3.0/us/ Divisibility, Quotient and Remainder Prime Numbers and Factorization Greatest Common Divisor Modular Arithmetic February 13, 2009 The Theorems of Fermat and Euler 1 / 25 2 / 25 Divisibility a and b integers. b divides a if there is an integer q such that a qb Equivalently: b is a divisor of a b is a factor of a a is a multiple of b 23 divides 3266, because 3266 142 23 23 does not divide 2146, because 2146 93 23 7 (the remainder of 2146 by 23 is not zero). Every integer a divides 0: 0 0 a 0 does not divide any integer, with the exception of 0 itself. Quotient and remainder a and b integers, b 0. The quotient and remainder of a by b are the only integers q and r characterized by: 1. a qb r 2. br 0 and r b Divisor and remainder always have the same sign. This convention is consistent with Sage and Python. Notation: Quotient: a div b Remainder: a mod b 343 6 51 37: 343 div 51 6 and 343 mod 51 37 532 p 12q p 45q p 8q: 532 div p 45q 12 and 532 mod p 45q 8 3 / 25 4 / 25

Computing Quotient and Remainder Prime Numbers Greatest integer function: tx u denotes the largest integer that is not above x q a div b ta{bu r a mod b a qb 20 div 7 t20{7u t2.857142...u 2 and 20 mod 7 20 2 7 6 20 div p 7q t20{p 7qu t 2.857142...u 3 and 20 mod p 7q 20 p 3q p 7q 1 We say that the integer a is prime if: 1. a 1 2. The only positive divisors of a are 1 and a itself. 1 is not prime. Only positive integers can be prime, according to our definition. 2,3,5,7,11,13,...,101,...,2 43,112,609 1. If a 1 is not prime, it is said to be composite 0 and 1 are neither prime nor composite. 5 / 25 6 / 25 The Fundamental Theorem of Arithmetic Factoring by Trial Division Every positive integer can be written as product of primes, and this prime factorization is unique, except for the order of the factors. We write a prime factorization as: a p t1 1 pt2 2 ptk k k¹ The prime numbers p1, p2,...,pk are distinct and the exponents t1, t2,...,tk are positive i1 83853 3 2 7 1 11 3 11 3 7 1 3 2 11 3 3 2 7 1 2 27 1 59649589127497217 5704689200685129054721 p ti i Example: factor a 7162722 a p 527560 2 263780 2 131890 2 65945 5 13189 11 1199 11 109 109 1 527560 2 3 5 11 2 109 Can stop when the square of latest prime factor is larger than unfactored part (11 2 121 109), since every composite b has a nontrivial factor less? b 7 / 25 8 / 25

Greatest Common Divisor a and b integers, not both 0. gcdpa, bq largest integer that divides both a and b gcdpa, 0q a for a 0. (gcdp0, 0q is undefined.) Euclidean algorithm: 1. r0 a, r1 b. 2. For i 1: ri 1 ri mod ri 1. 3. Stop when rn 0. Then, gcdpa, bq rn 1. Example: gcdp2420, 1650q i ri 0 2420 1 1650 2 770 4 110 5 0 gcdp2450, 1650q 110 The Extended Euclidean Algorithm a, b, integers, not both zero 1. x0 1, y0 0, r0 a 2. x1 0, y1 1, r1 b 3. For i 1: 3.1 qi ri 1 div ri 3.2 xi 1 xi 1 qixi 3.3 yi 1 yi 1 qy yi 3.4 ri 1 ri 1 qiri 4. Stop when ri 0. (next row) (previous row) qi (current row) The ri are the same sequence of remainders of the Euclidean algorithm. All rows satisfy the relationship: axi byi ri 9 / 25 10 / 25 An Example Linear Diophantine Equations a 2420, b 1650 i xi yi ri qi 0 1 0 2420 1 0 1 1650 1 2 1 1 770 2 4 2 3 110 7 5 0 Conclusion: gcdp2420, 1650q 110 and 2420 p 2q 1650 3 110. a, b integers, not both zero. The equation ax by gcdpx, yq always has integer solutions. A solution can be found by the extended euclidean algorithm. The equation ax by c has integers solutions if and only if gcdpa, bq divides c The equation ax by 1 has integer solutions if and only if gcdpa, bq 1. In this case, a, b are said to be relatively prime or coprime. 11 / 25 12 / 25

Definition of Congruence An Example a, b are congruent modulo m if and only if m divides a b Notation: a b pmod mq a b pmod mq if and only if a and b leave the same remainder when divided by m. a 0 pmod mq if and only if m divides a. For a given modulo m, the congruence relation is an equivalence relation. Cogruence is compatible with addition and multiplication: a b pmod mq and c d pmod mq imply a c b d pmod mq and ac bd pmod mq Compute 12 2009 mod 19 Start computing: 1. 12 2 144 11 pmod 19q 2. 12 3 11 12 132 18 1 pmod 19q 3. 12 4 1 12 12 7 pmod 19q 4. 12 5 7 12 84 8 pmod 19q 5. 12 6 8 12 96 1 pmod 19q Division of 2009 by 6 gives 2009 334 6 5 12 2009 12 334 6 5 12 6 334 12 5 1 8 8 pmod 19q 13 / 25 14 / 25 Linear Congruences Solving Linear Congruences A linear congruence is an equation: ax b pmod mq ax b The linear congruence is equivalent to: pmod mq m ax b, that is, ax b my for some y which is in turn equivalent to: ax my b The linear congruence has solutions if and only if gcdpa, mq divides b. 1. Use the extended euclidean algorithm to solve: au mv g where g gcdpa, mq 2. If g gcdpa, mq b, the equation has the solution: x0 ub{g 3. A maximal set of noncongruent solutions is: tx0, x0 d, x0 2d,..., x0 pg 1qdu where d m{g. The number of noncongruent solutions is g gcdpa, mq 15 / 25 16 / 25

Example Multiplicative Inverses Modulo m 35x 10 pmod 240q a is invertible modulo m if there is a x such that: The extended euclidean algorithm gives gcdp35, 240q 5 and 35 p 41q 240 6 5 Multiplying by 10{5 2 we get one solution: x0 2 p 41q 82 158 pmod 240q The stepsize is 240{5 48, and we get the solutions: {158, 158 48, 158 2 48, 158 3 48, 158 4 48u, which reduced modulo 240 give: t158, 206, 14, 62, 110u ax 1 pmod mq, in which case x is said to be an inverse of a modulo m. a is invertible modulo m if and only if gcdpa, mq 1 If it exists, the inverse of a is unique modulo m, that is, if x1 and x2 both satify the equation above, then x1 x2 pmod mq a 1 mod m denotes the inverse x of a such that 0 x m. 17 / 25 18 / 25 Examples 1. Find the inverse (if it exists) of 65 modulo 321. Solution: The extended euclidean algorithm gives: Congruence Classes The congruence class of a modulo m is the set: 65 p 79q 321 16 1 ras tx P Z x a pmod mqu Since gcdp65, 321q 1, the inverse exists, and one inverse of 65 modulo 321 is 79. Thus: 65 1 mod 321 79 mod 321 242 2. Find the inverse (if it exists) of 214 modulo 321. Solution: The extended euclidean algorithm gives: 214 107 321 p 160q 107, and since gcdp214, 321q 107 1, 214 is not invertible modulo 321. if m 6: r0s t..., 12, 6, 0, 6, 12,...u r1s t..., 11, 5, 1, 7, 13,...u r4s t..., 18, 2, 4, 10, 16,...u r10s r4s because 10 4 pmod 6q Any element b in ras is said to be a representative of the congruence class ras, and rbs ras. The set of congruence classes modulo m is: Z{mZ tr0s, r1s,..., rm 1su 19 / 25 20 / 25

Operations in Z{mZ Fermat s Theorem ras rbs ra bs and rasrbs rabs Definition is consistent, that is, it does not depend on the representatives chosen for the congruence classes. in Z{6Z, we have: r2s r3s r5s, r2sr3s r6s r0s, r5sr5s r25s r1s, r35sr1000s r 1sr4s r 4s r2s pz{mz,, q is a commutative ring: Addition and multiplication are defined, and have the usual properties : commutative, associative, is distributive with respect to, 1 is the identity of multiplication, etc. Elements are not required to have a multiplicative inverse: ras is invertible if and only if gcdpa, mq 1, and then ras 1 ra 1 mod ms. From now on, the modulus is a prime number p. Every a that is not a multiple of p is invertible modulo p Cancellation law: if ab ac and a is not a multiple of p, then b c pmod pq If p a, the two lists of integers: 1, 2,..., p 1 and 1a, 2a, pp 1qa consist of the same integers, modulo p Thus: 1 2 pp 1q 1a 2a pp 1qa pmod pq and, rearranging terms: 1 2 pp 1q 1 2 pp 1q a p 1 pmod pq. Using cancellation again: a p 1 1 pmod pq. Example 21 / 25 Euler s φ function 22 / 25 Compute 12 2009 mod 19. 19 is prime and 12 is not a multiple of 19. Fermat s theorem gives: 12 18 1 pmod 19q Using division: 2009 111 18 11 12 2009 12 111 18 11 12 18 111 12 11 12 11 pmod 19q Computing 12 11 pmod 19q: 12 2 144 11 pmod 19q 12 4 11 2 121 7 pmod 19q 12 8 7 2 49 11 pmod 19q 12 11 12 8 2 1 11 11 12 7 12 84 8 pmod 19q φpaq number of integers in t1, 2,..., au that are relatively prime to a If the prime factorization of a is p t1 1 pt2 2 ptk k, then: φpaq p t1 1 1 pp1 1qp t2 1 tk 1 2 pp2 1q pk ppk 1q a 1 1 1 1 1 1 p1 p2 pk Example: Compute φp44982q. 44982 2 3 3 7 2 17 φp44982q 2 0 p2 1q 3 2 p3 1q 7 1 p7 1q 17 0 p17 1q 12096 23 / 25 24 / 25

Euler s Theorem Let a and m be integers. If gcdpa, mq 1, then: a φpmq 1 pmod mq Example: compute 13 1233797 mod 44982 φp44982q 12096 and gcdp13, 44982q 1. so, by Euler s thoerem: 13 12096 1 pmod 44982q 1233797 102 12096 5 13 1233797 13 102 12096 5 13 5 11437 pmod 44982q 25 / 25