a crash course in elementary number theorya crash course in elementary number theory l. felipe...

25
Outline Divisibility, Quotient and Remainder Prime Numbers and Factorization Greatest Common Divisor Modular Arithmetic The Theorems of Fermat and Euler A Crash Course in Elementary Number Theory L. Felipe Martins Department of Mathematics Cleveland State University [email protected] Work licensed under a Creative Commons License available at http://creativecommons.org/licenses/by-nc-sa/3.0/us/ February 13, 2009 1 / 25

Upload: others

Post on 21-Jun-2020

16 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: A Crash Course in Elementary Number TheoryA Crash Course in Elementary Number Theory L. Felipe Martins Department of Mathematics Cleveland State University l.martins@csuohio.edu Work

OutlineDivisibility, Quotient and Remainder

Prime Numbers and FactorizationGreatest Common Divisor

Modular ArithmeticThe Theorems of Fermat and Euler

A Crash Course in Elementary Number Theory

L. Felipe MartinsDepartment of MathematicsCleveland State University

[email protected] licensed under a Creative Commons License available at

http://creativecommons.org/licenses/by-nc-sa/3.0/us/

February 13, 2009

1 / 25

Page 2: A Crash Course in Elementary Number TheoryA Crash Course in Elementary Number Theory L. Felipe Martins Department of Mathematics Cleveland State University l.martins@csuohio.edu Work

OutlineDivisibility, Quotient and Remainder

Prime Numbers and FactorizationGreatest Common Divisor

Modular ArithmeticThe Theorems of Fermat and Euler

1 Divisibility, Quotient and Remainder

2 Prime Numbers and Factorization

3 Greatest Common Divisor

4 Modular Arithmetic

5 The Theorems of Fermat and Euler

2 / 25

Page 3: A Crash Course in Elementary Number TheoryA Crash Course in Elementary Number Theory L. Felipe Martins Department of Mathematics Cleveland State University l.martins@csuohio.edu Work

OutlineDivisibility, Quotient and Remainder

Prime Numbers and FactorizationGreatest Common Divisor

Modular ArithmeticThe Theorems of Fermat and Euler

Divisibility

a and b integers.

b divides a if there is an integer q such that a � qb

Equivalently:

b is a divisor of ab is a factor of aa is a multiple of b

Examples:

23 divides 3266, because 3266 � 142 � 23

23 does not divide 2146, because 2146 � 93 � 23 � 7 (theremainder 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.3 / 25

Page 4: A Crash Course in Elementary Number TheoryA Crash Course in Elementary Number Theory L. Felipe Martins Department of Mathematics Cleveland State University l.martins@csuohio.edu Work

OutlineDivisibility, Quotient and Remainder

Prime Numbers and FactorizationGreatest Common Divisor

Modular ArithmeticThe Theorems of Fermat and Euler

Quotient and remainder

a and b integers, b � 0.The quotient and remainder of a by b are the only integers q and rcharacterized by:

1 a � qb � r2 br ¥ 0 and |r |   |b|

Divisor and remainder always have the same sign. This convention isconsistent with Sage and Python.Notation:

Quotient: a div bRemainder: a mod b

Examples:

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 and532 mod p�45q � �8

4 / 25

Page 5: A Crash Course in Elementary Number TheoryA Crash Course in Elementary Number Theory L. Felipe Martins Department of Mathematics Cleveland State University l.martins@csuohio.edu Work

OutlineDivisibility, Quotient and Remainder

Prime Numbers and FactorizationGreatest Common Divisor

Modular ArithmeticThe Theorems of Fermat and Euler

Computing Quotient and Remainder

Greatest integer function: txu denotes the largest integer that is notabove x

q � a div b � ta{bu

r � a mod b � a � qb

Examples:

20 div 7 � t20{7u � t2.857142 . . .u � 2 and20 mod 7 � 20 � 2 � 7 � 6

20 div p�7q � t20{p�7qu � t�2.857142 . . .u � �3 and20 mod p�7q � 20 � p�3q � p�7q � �1

5 / 25

Page 6: A Crash Course in Elementary Number TheoryA Crash Course in Elementary Number Theory L. Felipe Martins Department of Mathematics Cleveland State University l.martins@csuohio.edu Work

OutlineDivisibility, Quotient and Remainder

Prime Numbers and FactorizationGreatest Common Divisor

Modular ArithmeticThe Theorems of Fermat and Euler

Prime Numbers

We say that the integer a is prime if:1 a ¡ 12 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.

Examples: 2,3,5,7,11,13,. . . ,101,. . . ,243,112,609 � 1.

If a ¡ 1 is not prime, it is said to be composite

0 and 1 are neither prime nor composite.

6 / 25

Page 7: A Crash Course in Elementary Number TheoryA Crash Course in Elementary Number Theory L. Felipe Martins Department of Mathematics Cleveland State University l.martins@csuohio.edu Work

OutlineDivisibility, Quotient and Remainder

Prime Numbers and FactorizationGreatest Common Divisor

Modular ArithmeticThe Theorems of Fermat and Euler

The Fundamental Theorem of Arithmetic

Every positive integer can be written as product of primes, and thisprime factorization is unique, except for the order of the factors.

We write a prime factorization as:

a � pt11 pt2

2 � � � ptkk �

k¹i�1

ptii

The prime numbers p1, p2, . . . ,pk are distinct and the exponents t1,t2, . . . ,tk are positive

Examples:

83853 � 32 � 71 � 113 � 113 � 71 � 32 � 113 � 32 � 71

227 � 1 � 59649589127497217 � 5704689200685129054721

7 / 25

Page 8: A Crash Course in Elementary Number TheoryA Crash Course in Elementary Number Theory L. Felipe Martins Department of Mathematics Cleveland State University l.martins@csuohio.edu Work

OutlineDivisibility, Quotient and Remainder

Prime Numbers and FactorizationGreatest Common Divisor

Modular ArithmeticThe Theorems of Fermat and Euler

Factoring by Trial Division

Example: factor a � 7162722a p

527560 2263780 2131890 2

65945 513189 11

1199 11109 109

1

527560 � 23 � 5 � 112 � 109Can stop when the square of latest prime factor is larger thanunfactored part (112 � 121 ¡ 109), since every composite b has anontrivial factor less

?b

8 / 25

Page 9: A Crash Course in Elementary Number TheoryA Crash Course in Elementary Number Theory L. Felipe Martins Department of Mathematics Cleveland State University l.martins@csuohio.edu Work

OutlineDivisibility, Quotient and Remainder

Prime Numbers and FactorizationGreatest Common Divisor

Modular ArithmeticThe Theorems of Fermat and Euler

Greatest Common Divisor

a and b integers, not both 0.gcdpa, bq � largest integer that divides both a and bgcdpa, 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, 1650qi ri0 24201 16502 7704 1105 0

gcdp2450, 1650q � 110

9 / 25

Page 10: A Crash Course in Elementary Number TheoryA Crash Course in Elementary Number Theory L. Felipe Martins Department of Mathematics Cleveland State University l.martins@csuohio.edu Work

OutlineDivisibility, Quotient and Remainder

Prime Numbers and FactorizationGreatest Common Divisor

Modular ArithmeticThe Theorems of Fermat and Euler

The Extended Euclidean Algorithm

a, b, integers, not both zero1 x0 � 1, y0 � 0, r0 � a2 x1 � 0, y1 � 1, r1 � b3 For i ¥ 1:

1 qi � ri�1 div ri2 xi�1 � xi�1 � qixi

3 yi�1 � yi�1 � qyyi

4 ri�1 � ri�1 � qi ri

4 Stop when ri � 0.

(next row) � (previous row) � qi � (current row)

The ri are the same sequence of remainders of the Euclideanalgorithm.

All rows satisfy the relationship: axi � byi � ri

10 / 25

Page 11: A Crash Course in Elementary Number TheoryA Crash Course in Elementary Number Theory L. Felipe Martins Department of Mathematics Cleveland State University l.martins@csuohio.edu Work

OutlineDivisibility, Quotient and Remainder

Prime Numbers and FactorizationGreatest Common Divisor

Modular ArithmeticThe Theorems of Fermat and Euler

An Example

a � 2420, b � 1650

i xi yi ri qi

0 1 0 2420 —1 0 1 1650 12 1 �1 770 24 �2 3 110 75 — — 0

Conclusion: gcdp2420, 1650q � 110 and2420 � p�2q � 1650 � 3 � 110.

11 / 25

Page 12: A Crash Course in Elementary Number TheoryA Crash Course in Elementary Number Theory L. Felipe Martins Department of Mathematics Cleveland State University l.martins@csuohio.edu Work

OutlineDivisibility, Quotient and Remainder

Prime Numbers and FactorizationGreatest Common Divisor

Modular ArithmeticThe Theorems of Fermat and Euler

Linear Diophantine Equations

a, b integers, not both zero.

The equation ax � by � gcdpx , yq always has integer solutions. Asolution can be found by the extended euclidean algorithm.

The equation ax � by � c has integers solutions if and only ifgcdpa, bq divides c

The equation ax � by � 1 has integer solutions if and only ifgcdpa, bq � 1. In this case, a, b are said to be relatively prime orcoprime.

12 / 25

Page 13: A Crash Course in Elementary Number TheoryA Crash Course in Elementary Number Theory L. Felipe Martins Department of Mathematics Cleveland State University l.martins@csuohio.edu Work

OutlineDivisibility, Quotient and Remainder

Prime Numbers and FactorizationGreatest Common Divisor

Modular ArithmeticThe Theorems of Fermat and Euler

Definition of Congruence

a, b are congruent modulo m if and only if m divides a � b

Notation: a � b pmod mqa � b pmod mq if and only if a and b leave the same remainderwhen divided by m.

a � 0 pmod mq if and only if m divides a.

For a given modulo m, the congruence relation is an equivalencerelation.

Cogruence is compatible with addition and multiplication: a � bpmod mq and c � d pmod mq imply a � c � b � d pmod mq andac � bd pmod mq

13 / 25

Page 14: A Crash Course in Elementary Number TheoryA Crash Course in Elementary Number Theory L. Felipe Martins Department of Mathematics Cleveland State University l.martins@csuohio.edu Work

OutlineDivisibility, Quotient and Remainder

Prime Numbers and FactorizationGreatest Common Divisor

Modular ArithmeticThe Theorems of Fermat and Euler

An Example

Compute 122009 mod 19

Start computing:1 122 � 144 � 11 pmod 19q2 123 � 11 � 12 � 132 � 18 � �1 pmod 19q3 124 � �1 � 12 � �12 � 7 pmod 19q4 125 � 7 � 12 � 84 � 8 pmod 19q5 126 � 8 � 12 � 96 � 1 pmod 19q

Division of 2009 by 6 gives 2009 � 334 � 6 � 5

122009 � 12334�6�5 � �126�334 � 125 � 1 � 8 � 8 pmod 19q

14 / 25

Page 15: A Crash Course in Elementary Number TheoryA Crash Course in Elementary Number Theory L. Felipe Martins Department of Mathematics Cleveland State University l.martins@csuohio.edu Work

OutlineDivisibility, Quotient and Remainder

Prime Numbers and FactorizationGreatest Common Divisor

Modular ArithmeticThe Theorems of Fermat and Euler

Linear Congruences

A linear congruence is an equation:

ax � b pmod mq

The linear congruence is equivalent to:

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 dividesb.

15 / 25

Page 16: A Crash Course in Elementary Number TheoryA Crash Course in Elementary Number Theory L. Felipe Martins Department of Mathematics Cleveland State University l.martins@csuohio.edu Work

OutlineDivisibility, Quotient and Remainder

Prime Numbers and FactorizationGreatest Common Divisor

Modular ArithmeticThe Theorems of Fermat and Euler

Solving Linear Congruences

ax � b pmod mq

1 Use the extended euclidean algorithm to solve:

au �mv � g where g � gcdpa,mq2 If g � gcdpa,mq � b, the equation has the solution:

x0 � ub{g3 A maximal set of noncongruent solutions is:

tx0, x0 � d , x0 � 2d , . . . , x0 � pg � 1qduwhere d � m{g . The number of noncongruent solutions isg � gcdpa,mq

16 / 25

Page 17: A Crash Course in Elementary Number TheoryA Crash Course in Elementary Number Theory L. Felipe Martins Department of Mathematics Cleveland State University l.martins@csuohio.edu Work

OutlineDivisibility, Quotient and Remainder

Prime Numbers and FactorizationGreatest Common Divisor

Modular ArithmeticThe Theorems of Fermat and Euler

Example

35x � 10 pmod 240q

The extended euclidean algorithm gives gcdp35, 240q � 5 and35 � p�41q � 240 � 6 � 5

Multiplying by 10{5 � 2 we get one solution:x0 � 2 � p�41q � �82 � 158 pmod 240qThe “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

17 / 25

Page 18: A Crash Course in Elementary Number TheoryA Crash Course in Elementary Number Theory L. Felipe Martins Department of Mathematics Cleveland State University l.martins@csuohio.edu Work

OutlineDivisibility, Quotient and Remainder

Prime Numbers and FactorizationGreatest Common Divisor

Modular ArithmeticThe Theorems of Fermat and Euler

Multiplicative Inverses Modulo m

a is invertible modulo m if there is a x such that:

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 mqa�1 mod m denotes the inverse x of a such that 0 ¤ x   |m|.

18 / 25

Page 19: A Crash Course in Elementary Number TheoryA Crash Course in Elementary Number Theory L. Felipe Martins Department of Mathematics Cleveland State University l.martins@csuohio.edu Work

OutlineDivisibility, Quotient and Remainder

Prime Numbers and FactorizationGreatest Common Divisor

Modular ArithmeticThe Theorems of Fermat and Euler

Examples

1 Find the inverse (if it exists) of 65 modulo 321.Solution: The extended euclidean algorithm gives:

65 � p�79q � 321 � 16 � 1

Since gcdp65, 321q � 1, the inverse exists, and one inverse of 65modulo 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 modulo321.

19 / 25

Page 20: A Crash Course in Elementary Number TheoryA Crash Course in Elementary Number Theory L. Felipe Martins Department of Mathematics Cleveland State University l.martins@csuohio.edu Work

OutlineDivisibility, Quotient and Remainder

Prime Numbers and FactorizationGreatest Common Divisor

Modular ArithmeticThe Theorems of Fermat and Euler

Congruence Classes

The congruence class of a modulo m is the set:

ras � tx P Z | x � a pmod mquExamples: if m � 6:r0s � t. . . ,�12,�6, 0, 6, 12, . . .ur1s � t. . . ,�11,�5, 1, 7, 13, . . .ur4s � t. . . ,�18,�2, 4, 10, 16, . . .ur10s � r4s because 10 � 4 pmod 6qAny element b in ras is said to be a representative of the congruenceclass ras, and rbs � ras.The set of congruence classes modulo m is:

Z{mZ � tr0s, r1s, . . . , rm � 1su20 / 25

Page 21: A Crash Course in Elementary Number TheoryA Crash Course in Elementary Number Theory L. Felipe Martins Department of Mathematics Cleveland State University l.martins@csuohio.edu Work

OutlineDivisibility, Quotient and Remainder

Prime Numbers and FactorizationGreatest Common Divisor

Modular ArithmeticThe Theorems of Fermat and Euler

Operations in Z{mZ

ras � rbs � ra � bs and rasrbs � rabsDefinition is consistent, that is, it does not depend on therepresentatives chosen for the congruence classes.

Examples: in Z{6Z, we have:r2s � r3s � r5s, r2sr3s � r6s � r0s, r5sr5s � r25s � r1s,r35sr1000s � r�1sr4s � r�4s � r2spZ{mZ,�, �q is a commutative ring:

Addition and multiplication are defined, and have the “usualproperties”: commutative, associative, � is distributive with respect to�, 1 is the identity of multiplication, etc.Elements are not required to have a multiplicative inverse: ras isinvertible if and only if gcdpa,mq � 1, and thenras�1 � ra�1 mod ms.

21 / 25

Page 22: A Crash Course in Elementary Number TheoryA Crash Course in Elementary Number Theory L. Felipe Martins Department of Mathematics Cleveland State University l.martins@csuohio.edu Work

OutlineDivisibility, Quotient and Remainder

Prime Numbers and FactorizationGreatest Common Divisor

Modular ArithmeticThe Theorems of Fermat and Euler

Fermat’s Theorem

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 � cpmod pqIf 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 � ap�1 pmod pq.Using cancellation again: ap�1 � 1 pmod pq.

22 / 25

Page 23: A Crash Course in Elementary Number TheoryA Crash Course in Elementary Number Theory L. Felipe Martins Department of Mathematics Cleveland State University l.martins@csuohio.edu Work

OutlineDivisibility, Quotient and Remainder

Prime Numbers and FactorizationGreatest Common Divisor

Modular ArithmeticThe Theorems of Fermat and Euler

Example

Compute 122009 mod 19.

19 is prime and 12 is not a multiple of 19.

Fermat’s theorem gives: 1218 � 1 pmod 19qUsing division: 2009 � 111 � 18 � 11

122009 � 12111�18�11 � �1218�111 � 1211 � 1211 pmod 19q

Computing 1211 pmod 19q:122 � 144 � 11 pmod 19q124 � 112 � 121 � 7 pmod 19q128 � 72 � 49 � 11 pmod 19q1211 � 128�2�1 � 11 � 11 � 12 � 7 � 12 � 84 � 8 pmod 19q

23 / 25

Page 24: A Crash Course in Elementary Number TheoryA Crash Course in Elementary Number Theory L. Felipe Martins Department of Mathematics Cleveland State University l.martins@csuohio.edu Work

OutlineDivisibility, Quotient and Remainder

Prime Numbers and FactorizationGreatest Common Divisor

Modular ArithmeticThe Theorems of Fermat and Euler

Euler’s φ function

φpaq � number of integers in t1, 2, . . . , au that are relatively prime to a

If the prime factorization of a is pt11 pt2

2 � � � ptkk , then:

φpaq � pt1�11 pp1 � 1qpt2�1

2 pp2 � 1q � � � ptk�1k ppk � 1q

� a

�1 � 1

p1

�1 � 1

p2

� � ��

1 � 1

pk

Example: Compute φp44982q.44982 � 2 � 33 � 72 � 17φp44982q � 20�p2�1q�32�p3�1q�71�p7�1q�170p17�1q � 12096

24 / 25

Page 25: A Crash Course in Elementary Number TheoryA Crash Course in Elementary Number Theory L. Felipe Martins Department of Mathematics Cleveland State University l.martins@csuohio.edu Work

OutlineDivisibility, Quotient and Remainder

Prime Numbers and FactorizationGreatest Common Divisor

Modular ArithmeticThe Theorems of Fermat and Euler

Euler’s Theorem

Let a and m be integers. If gcdpa,mq � 1, then:

aφpmq � 1 pmod mqExample: compute 131233797 mod 44982

φp44982q � 12096 and gcdp13, 44982q � 1. so, by Euler’s thoerem:1312096 � 1 pmod 44982q1233797 � 102 � 12096 � 5131233797 � 13102�12096�5 � 135 � 11437 pmod 44982q

25 / 25