<<

Modular

Divisibility Given p ositive numb ers a b if a we can write

b aq r

1

for appropriate q r such that r a The numb er r

is the We say that a divides b or ajb if r and so

b aq ie b factors as a times q

Primes A numb er is prime if it cant b e factored as a pro duct

of two numb ers greater or equal to If a numb er factors ie it is

not prime then we say that it is comp osite

Exercise Find all prime numb ers smaller than

Here are several imp ortant questions

How do we determine whether a numb er is prime

How do we factor a numb er into primes

How can we nd big prime numb ers

How many prime numb ers are there

Exercise Factor

Exercise Show that every numb er is either prime or divisible by

a prime numb er

Theorem There are innitely many prime

Proof Supp ose that there are only nitely many prime numb ers P P

1 n

then N P P P is not divisible by any prime hence it do es

1 2 n

factor and hence it is a new prime not ˜

Divisibility tricks Recall that a numb er is even if its last digit

is divisible by it is divisible by if the sum of its digits is divisible

by it is divisible by if its last digit is divisible by etc

Why is this Can we nd other divisibility tricks eg for

One p ossible explanation Let abc b e a digit numb er so that abc

a b c Then

abc a b c and this is an only if c is an

integer

abc a b c and this is an integer only if c is an

integer

abc a b a b c and this is an integer only if

a b c is an integer

A b etter explanation is given by congruences

1

In Python notation r ba and q ba 1

2

Congruences We say that a is congruent to b mo dulo N ie

a b mod N i N divides a b or equivalently i aN bN So a

is congruent mo dulo N to any numb er in the arithmetic progression

f a N a N a a N a N g

Here are some examples

mod

mod

mod

mod

Exercise Is divisible by How ab out

100

Exercise What is the last digit of

111

Of

What are the last two digits of the numb ers ab ove

Solution Every integer mo dulo is congruent to one of

f g

we call this a system of residues mo dulo We now compute the

100

residue of We have

2 3 4

Then

100 4 25 25

Arithmetic of residues mo dular arithmetic Residues mo d

ulo f g

Z

Exercise Write down the and tables

We can compute etc We have

Check Now ab makes little sense eg

1 1

what do es mean We should write a b eg From the

1

multiplication table we see that so that and then

1

Exercise Write down the addition and multiplication ta

bles for

Z Z

Find the additive and multiplicative inverses of mo d

mo d mo d and mo d

Find the of mo d

Find the orders of mo d Do you see a pattern

2 2

Can you solve x mo d and x mo d

Show that if a b c d then a b b d and ac bd

3

The Euclidean

The greatest common By denition the greatest com

mon divisor of two numb ers a b is the largest numb er that divides

b oth a and b We denote it by GC D a b or just by a b Eg

To see the last one write

and so that the sets of are

f g and f g

We can compute the GCD in the following ways

By brute force Find all the divisors and compare

Find all divisors of a and throw out the ones that do not divide

b

Compare prime factors and multiply the highest p owers that

divide b oth numb ers

The

The Euclidean algorithm is by far the fastest metho d for big numb ers

The Euclidean algorithm Start with a b and

let r ab b e the remainder Replace a by b and b by r and rep eat

The last nonzero remainder is the GCD

a b r q

The GCD is

Exercise Find the GCD of and of

Exercise Factor the ab ove numb ers

Python Co de def gcdab

rab

print abr

while r

abr brbr

print abr

return b

It works as follows

gcd

Well ordering principle Each nonempty set of positive integers

has a least element

4

Note that this is not true for the rationals Eg has no smallest 0

Q

numb er

Prop osition Given positive integers a b let S fax by g

where x y are any integers Let g be the least element in S then

g GC D a b

Proof It is enough to show that g divides GC D a b and that GC D a b

divides g

Clearly GC D a b divides a and b so it divides any element in S and

so it divides g

To see that g divides GC D a b it is enough to show that g divides

a and that g divides b Consider a g q r then r a g q

a ax by q q ax bq y Now r g and so r

else r S contradicting the fact that g is the smallest element of S

Therefore g divides a and by the same argument it divides b and so

divides GC D a b it ˜

So we can always write

GC D a b ax by

This allows us to nd the inverse of any numb er a p mo dulo

p when p is prime In fact GC D a p so we have ax py so

1

mo dulo p we have ax ie x a mo dulo p

Finding x and y Use back substitution Eg for a

b then GC D a b Recall that

a b r q

So and

Then

Exercise Solve

x y

x y

Exercise Find the of

mo d

mo d

5

Python co de for the Extended Euclidean Algorithm

def egcdab

qr divmo dab

xyuvq

while r

qqrr divmo dbr

xxyyuqqxvqqy

abrqxyuvbrrrqqxxyyxy

print abrqxyuv

return uvb

Exercise What are the last digits of the multiplicative inverse

100

of mo d

Exercise I have enco ded my SSN using the algorithm f x x

10

mo d The result is What is my SSN You will need

a that can compute with digit numb ers eg python

Modular Powers

We b egin by writing a table for the p owers mo dulo

Mo dulo

2 3 4 5 6 7

a a a a a a a

Note that after we get a column with all s and a at the top

the pattern must rep eat Therefore as so on as and if this happ ens

the table just keeps rep eating itself and so we do not b other to keep

writing the rep eated entries

Mo dulo

2 3 4 5 6 7

a a a a a a a

Here the th column has all s and a at the top

Mo dulo

2 3 4 5 6 7

a a a a a a a

6

Do you notice a pattern The rst pattern seems to b e that for all

2 4 6

a we have a mo d a mo d a mo d It is easy

to guess what the general pattern might b e

Theorem Fermats Little Theorem Let p be any prime and

a p Then

p1

a mo d p

22 22

Eg mo d Check Similarly

100 100

mo d Note that has more than digits so

checking explicitly might not b e so easy

Proof We claim that the set fa a p ag is the same as the set

f p g the elements are not in the same order Granting

the claim then we have

p1

p a a p a p a

Since p do es not divide p it follows that GC D p p

so there is a numb er x p such that x p

mo d p But then

p1 p1

x p x p a a

as required

To see the claim we must check that

The map x ax mo d p induces a map

f p g fa a p ag

Ie that for all x p we have that p do es not divide ax This

is clear as p is a prime numb er that do es not divide either of a and x

If x y p then ax ay mo d p ie this function is

to Supp ose in fact that ax ay mo d p As GC D a p there

is a numb er b such that ba mo d p Therefore bax bay so that

y x ˜

12345

Exercise Compute mo d

12345

Exercise Compute mo d

Exercise Compute the order of mo d and

Can you make a guess ab out the general pattern

Eulers function How do es Fermats Little Theorem general

ize to numb ers m that are not prime The key thing in the pro of is that

f p g are coprime with p so that they have multiplicative

inverses in It is then natural to dene

Zp

m fa a m and GC D a m g

This is Eulers function We now compute its value for some ms

p p for all prime numb ers p Eg

7

f g

f

g

2 2

p p p for any prime numb er p To see this note that

2

in the list f p g we must erase p p p p so we

2 2

have p p p p entries

n n n1

p p p for any prime numb er p Explain this in

detail

f g

f g

f g

f g

p q p q for any prime numb ers p q To see this

note that in the list f pq g we must erase p p q

p and q q p q so we have pq p q

p q entries

m n m n whenever GC D m n

Exercise Prove the last fact

Exercise Compute

Theorem Eulers Formula If GC D a m then

(m)

a mo d m

5243

Exercise Compute mo d

90

Exercise Compute mo d Is prime

m

So if we pick a random numb er a m and we have a a mo d

m

m then m is not prime If a a mo d m then m mayb e prime

m

If a a mo d m for many as then m is probably prime

m

Exercise There are some comp osite numb ers such that a a

mo d m for all a m Can you nd one

1000000000

Powers mo d m How would you compute mo d

by hand Or mayb e with a p o cket calculator

so

9 1000000000 2200

so mo d

2 4 2 8 2 16 2

32 64 128 256 512

1024 2048

Now so

2200

mo d

This was remarkably quick It turns out that we did not need to

p erform op erations Just ab out l og so ab out

2

op erations note that in base the numb er is

1000000000

mo d mo d mo d Exercise Compute

8

Exercise Estimate the numb er of doublings needed to compute

100

10 2

mo d

9990

Exercise Compute mo d without factoring Is

prime Factor

k th ro ots mo d m We wish to solve the equation

k

x b mo dm

5

For example x mo d

We have that and so

Now GC D and so we can invert mo dulo We

must write u mo d We use the Euclidean Algorithm to

get Therefore

5 3917 97922+1 9792 2

x x x x x mo d

3917

So x mo d

k

The general strategy to solve x b mo d m where GC D b m

and GC D k m is exactly the same

We compute m This is easy if we can factor m

Write k u mv Use the Euclidean Algorithm

1+(m)v k u u u

Then x x x b Compute b via the metho d of

successive squaring

5 3

Exercise Solve x mo d and x mo d

RSA

The rst step is to convert the alphab et to numb ers Eg A

B C D E F G Y

Z So

GO O D M O R N I N G

This co de is very easy to break by frequency analysis So we want to

jumble the numb ers up in a way that will lo ok completely random to

the co de breaker

Fix p q two very large primes eg to digits Let m pq so

that m p q Pick k with GC D k m

Everyone knows m k they are public

p q and hence m are secret

For example let p q so that m Pick

k

Break a message up in to numb ers m Eg

k

Let b a mo d m We compute this by rep eated squaring to

i

i

get the enco ded message b b This is made publicsent

1 r

77

to the intended receiver Eg b a mo d gives

i

i

9

k

To deco de solve x b mo d m So nd j with j k mo d

i

j

m Then a b mo d m Eg j Check that k j

i

i

8213

mo d and that mo d etc

This system is very easy to explain and implement on a computer

In order to deco de it you must know m So you must factor m

100

This is very hard Factoring a digit numb er requires ab out

computations In contrast it is easy to pro duce big primes We will

do this later

Question Couldnt we nd m without factoring m and so easily

break the co de

Answer No Since m pq if we know m p q

m p q then we know p q m m and so we can nd the

2

ro ots of x p q x m But these are the ro ots of x px q

and hence we have found p q

Exercise Enco de GOODMORNING using m digits at a

time Deco de

RSA signatures In practice each individual ABC will have

will have hisher secret primes p q and will make m p q and

A A A A A

k public

A

Anyone can encrypt a message and send it to A or B C etc Just

do

k

k

A

A

a a a a b b

1 r 1 r

1 r

We assume that b b is public or could b e intercepted

1 r

Only A can deco de this message since only A knows m so only

A

j

A

A can solve j k mo d m and then compute a b mo d m

A A A i A

i

Supp ose that A is exp ecting a message from B How do es A know

that it really comes from the friendly B and not from the evil C

B can attach a signature as follows

j

j

B

B

B AR T S I M P S O N mo d m

1 s B

1 s

Only B can do this Only B can nd j

B

Now B enco des his message with the signature app ended

j j

k

j k k j k

B B

A

B A A B A

a a b b b b a a

1 r 1 r r +1 r +s

1 s 1 r 1 s

j

B j

B

Only A can deco de the message and see a a But

1 r

1 s

everyone knows k so A can compute

B

j

k j k

B

B B B

B AR T S I M P S O N

1 s

1 s

So A can tell that B sent the message and no one else can

Counting large primes

We already know that there are innitely many prime numb ers but

how common are they

Eg Half of the numb ers are even

10

To b e more precise if we let

ev x fev en s n w ith n xg

then ev ev ev ev ev etc So

ev x x if x is even and ev x x if x is o dd Then

ev xx if x is even and ev xx x if x is o dd

Then ev xx and x Eg ev and

ev

We will now consider the function

x fpr imes p such that p xg

Exercise Find Use a computer to

nd

We have

x

x

xx

It would b e reasonable to guess that xx as x This

means that for any we have that for big values of x the inequality

x x

The Prime Numb er Theorem

Theorem We have that xxl nx as x ie

x

lim

x!1

xl nx

This means that for large x the numb er x is very close to xl nx

10 10 10

Eg l n l n So the

10

probability of a random numb er n b eing prime is

10

Exercise How many primes are there How many primes

10 10 5

with digits How many primes b etween and

Finding large primes

We would like to pro duce big prime numb ers eg with digits

We could pick a random numb er p with digits and try and divide

12 100 12 50

by all the numb ers p This would take way

to o long

Exercise How long would this take assuming we can p erform

divisions each second

We will happily settle for a numb er which is prime with probability

say

11

Primality testing How can we test if p is prime By Fermats

little theorem if p is prime then

p

a a mo d p for all a p

p p

So if a a mo d p then p is denitely not prime If a a mo d p

p p

a a a we have some evidence that p might b e prime If a

2 1

2 1

p

a a mo d p we are tempted to conclude that p is probably

100

100

prime But what is the actual probability Also do es this test detect

all nonprime numb ers

10 10 10 10 10 10

If n then and

mo d so we have negatives AKA witnesses and false p ositives

the numb ers Therefore this test is eective

Eg n has negativeswitnesses ie numb ers such that

p

a a mo d p So this test is accurate

Eg n accuracy Problem

561

satises a a mo d for all a The

test is accurate

561

Proof It is enough to show that a a

mo d

2 560 2 280 280

Mo dulo If GC D a then a so a a

10 560 10 5

Mo dulo If GC D a then a so a a

56

16 560 16 10

Mo dulo If GC D a then a so a a

10

˜

p

Numb ers with this prop erty a a mo d p for all a p are

called Carmichael numb ers

Eg are all the Carmichael

numb ers less than

So mayb e these numb ers are very rare and this is not a problem

Exercise Can you show that there are innitely many Carmichael

numb ers

560

Notice that mo d so mayb e we should b e testing

m1 m

for a mo d m not a a mo d m It would b e even b etter to

nd a test that always works

The Miller Rabin test

k

Theorem If p is prime then we write p q where q

is odd If a p then either

q

a mod p or

k 1

q 2q 4q 2 q

a or a or a or or a mod p

Proof We will use that fact that if p is prime then the only numb ers

k k 1

2 q p1 2 q

a so a that to mo d p are Now a

12

k 1 k 2

2 q 2 q

If a we are done otherwise a Rep eat this

q q

pro cedure until p ossibly a if its a we are in case

q

a and we are in case Otherwise ˜

Notice that for a comp osite numb er such as we may have many

more square ro ots of eg

The Rabin Miller test for prime numb ers works as follows Pick n

k q

any o dd integer and write n q with q o dd If a mo d n

i

2 q

and a mo d n for i k then n is comp osite

Theorem If n is composite and odd then at least of the

numbers between and n fail the Rabin Mil ler test So at least

of such numbers are RabinMil ler witnesses

So if n passes the test for random numb ers then n is not prime

100 200 60

with probability less than

Exercise Apply the RabinMiller test with a to n

The Primitive Element Theorem

We now return to the study of p owers of a numb er a mo d p where p is

prime By Fermats Little Theorem we know that for all a p

p1

we have a mo d p We would now like to answer the question

e

Are there any smal ler powers such that a mod p Let e a b e

p

e (a)

p

the smallest p ositive numb er such that a mo d p The numb er

e a is the exp onent of a mo d p

p

Exercise Find e a for a p and p Do you

p

see a pattern

There are two main observations that are true for all primes

Theorem Let p be any prime and a p Then

e a divides p

p

There are exactly p distinct numbers a p such

that e a p

p

Proof For if e a do es not divide p then g GC D e a p

p p

e a and we may write g xe a y p so that

p p

g xe (a)+y (p1) e (a) x p1 y x y

p p

a a a a

and this contradicts the fact that e a is the smallest integer such that

p

e

a mo d p

For we pro ceed as follows since e a always divides p we

p

b egin by counting how many as with exp onent e p are there

n

If p q where q is prime then if e a p we have that

p

n1

n1 q

e a divides q and hence a is a ro ot of the p olynomial x

p

n1 n n1

There are at most q such ro ots and so there are at least q q

n

n

1

r

with r then if e a p primitive ro ots If p q q

p

r 1

13

we have that e a divides p q or e a divides p q so

p 1 p 2

(p1)q (p1)q

2 1

There are at most x a is a ro ot of x

p q p q distinct ro ots of this equation the ro ot is

1 2

counted twice It follows that there are at least

p p q p q p

1 2

q q

1 2

1 1

primitive ro ots We have used the fact that q so that

i

q q

1 2

We have so far veried that there is at least one primitive ro ot say

g So we know that

2 p1

f p g fg g g g

i

as unordered sets The order of g is p exactly when GC D i p

exercise for the reader and so we have exactly p primitive ro ots

˜

Exercise Find an element of order mo d ie a primitive

element What are the other elements of order Find elements of

order Is there an element of order

Squares a prime

Exercise Is a square mo dulo Ie can we nd a numb er a

2

such that a mo d

Exercise Compute all squares mo d Do you notice

a pattern

Theorem Let p be a prime then there are p nonzero

squares mod p

2 2

Proof Clearly a a so there can b e at most p distinct

squares Supp ose that there are less than p squares then there

is a numb er say a which is the square of at least dierent numb ers

2

say b c d mo d p But then b c d are distinct ro ots of x a This is

2

imp ossible In fact then x b x c and x d all divide x a so

2

a is divisible by a degree equation which is imp ossible x ˜

2

Exercise Show that if p is a prime and a is a ro ot of x bx c

2

then a and b a are the only ro ots of x bx c

2

Exercise Find a numb er m and an equation x bx c that

2

has at least solution Conclude that x bx c has more than one

We will call the squares mo d p Quadratic Residues or just QR

The nonzero numb ers that are not QR will b e called Non Residues

or just NR

14

The next observation is that if a and b are squares mo dulo p then

ab is a square mo d p In other words

QR QR QR

Exercise What happ ens when you multiply QR NR NR

NR or NR QR mo d Exp eriment mo d Can you draw any

conclusions

Theorem Let p be a prime then modulo p we have that QR

QR QR QR NR NR QR NR and NR NR QR

Proof The primitive ro ot Theorem states that there is an integer g

2 p1

such that g g g gives all numb ers x p mo d p

The QRs are exactly the even p owers of g and the NR are the o dd

p owers So to verify that NR QR NR we take a nonresidue of

2k +1 2j

the form g and a residue of the form g and we multiply them to

2k +1 2j 2(k +j )+1

g g g which is not a residue as k j is o dd get ˜

So multiplying QRs and NRs b ehaves like multiplying and

It makes sense to dene the Legendre symb ol of a mo d p as follows

a a

if a is a QR mo d p and if a is a NR mo d p So if

p p

a is a QR and b is a NR mo d p then ab is a NR mo d p which can b e

expressed by the following equality

     

a b a

p p p

Exercise Find a primitive element mo d p Find all

QRs mo d p

Exercise Find the sum of all QRs a p mo d p

Do the same for the NRs Do you notice a pattern

1

Exercise Compute for p

p

Do you notice a pattern

The pattern is

 

if p mo d

p

 

if p mo d

p

This follows immediately from

Eulers Criterion If p is a prime then

 

a

(p1)2

mo d p a

p

1

2k

Clearly if p mo d then p k so that

p

1

2k +1

It and if p mo d then p k so that

p

remains to prove Eulers Criterion

15

2 (p1)2 p1

Proof If a is a QR then a b so that a b as required

If a is a NR then a is an o dd p ower of a primitive element ie

2k +1

a g so that

(p1)2 (2k +1)(p1)2 p1 k (p1)2 (p1)2

a g g g g

p1 (p1)2

Now g so that g but since e g p ie p

p

e (p1)2

the smallest p ower e such that g then g is ˜

Next we would like to determine When is a QR mod p Ie we

2

would like to compute for all o dd primes

p

2

for all primes p Do you see Exercise Determine

p

a pattern

The pattern which is hard to sp ot is

 

if p or mo d

p

 

if p or mo d

p

Proof We multiply the even numb ers

p

(p1)2

p

We now wish to rewrite the LHS p in a dierent way

Consider the numb ers p which are p p p

or equivalently So when we multiply p

we are actually multiplying all the even numb ers p and all

2

the o dd numb ers p with a minus sign Therefore

p

t

p

where t is the numb er of o dd integers a p Comparing

the two equations ab ove and canceling a p we get

(p1)2 t

mod p

We now can easily conclude via a case by case analysis

If p mo d then p k so that p k and t k

(p1)2 2k

Then mo d p and by Eulers Criterion is a

square mo d p

If p mo d then p k k k so that

p k k k and hence t k k k

(p1)2

and hence and by Eulers Criterion is a NR

QR mo d p NR ˜

1 2

Exercise Compute and for p

p p

2

Exercise Do es x x have a solution mo d

2

If p a p then p a so that p  a ie p  a

16

a

for any Quadratic recipro city We would like to compute

p

n

n

1

r

integer a p If we write a q q then we have

1 r

n

1 n

r

q

n

q

a

i

r

1

Now if n is even then q is clearly a square so

i

i

p p p

n n

i i

q q

q

i

i i

If n is o dd then Therefore we just need that

i

p p p

to compute

 

q

for any primes q p

p

q

Exercise Make a table for for the primes

p

Can you see a pattern Lo ok at the rows and columns for p

Now rub these out Is there a pattern

The pattern is the following

3

Theorem If p q are primes then

   

p q

if either p mo d or q mo d

p q

   

q p

if p mo d and q mo d

p q

44 51 91

Exercise Compute

53 101 127

We also have the Generalized Law of Quadratic Recipro city

Theorem Let a b be odd numbers then

1 1

if b mod and if b mod

b b

2 2

if b mod and if b mod

b b

a b a

if either a mo d or b mo d and

b a b

b

if a mo d and a mo d

a

Pythagorean triples

By denition a is an integer solution to the

2 2 2

equation a b c It yields a rectangle triangle with sides of integer

length a b c You are probably familiar with the Pythagorean triple

Exercise Can you nd any other Pythagorean triples

Of course is also a Pythagorean triple and so is a a a

for any p ositive integer a We will say that a b c is a primitive

2 2 2

Pythagorean triple if a b c and a b c have no common factors

is another such triple

1 3 1

if p mo d and if p Together with the rules

p p

2 2

mo d and if p  mo d and if p  mo d this is

p p

known as the Law of Quadratic Recipro city

17

Exercise Can you nd any other primitive Pythagorean triples

Can you show that there are innitely many such triples Write a

program to nd all such triples with a b

We would like to nd all primitive Pythagorean triples We notice

that if a and b are even then c is even so that is a common factor of

a b c and then a b c is not a primitive triple If a and b are b oth o dd

then a x b y and

2 2 2 2 2

c a b x x y y mo d

Now is not a square mo d so this is imp ossible Therefore we

conclude that the set a b are not b oth even or o dd So we may assume

that

a is o dd b is even and c is o dd

We now consider the factorization

2 2 2

a c b c bc b

We claim that Both c b and c b are squares

Proof First of all g GC D c b c b as otherwise g divides

c b and c b so that g divides c c b c b and g divides

b c b c b Since c b is o dd g is o dd so g divides c and

2 2 2 2

b and hence g divides a as g divides a c b so that as a b c

have no common factor we have g

So if p is a prime numb er such that p divides c b then p do es not

t t

divide c b Let p b e the highest p ower of p dividing c b then p is

2

the highest p ower of p dividing a c bc b Therefore t is even

n

n

1

r

and so if we write c b p p with p distinct primes we have

i

1 r

that all the n are even so that c b is a square The same reasoning

i

shows that c b is a square also ˜

So we write

2 2

c b s and c b t

where s t are o dd integers Therefore we have that

Theorem Al l primitive Pythagorean triples are of the form

2 2 2 2

s t s t

b and a st c

for some odd integers s t

Which prime numbers are sums of two squares

Exercise Find all prime numb ers that are sums of two

squares do you notice a pattern

The pattern is

Theorem A p is the sum of two squares if

and only if p mod

18

Proof If p is the sum of two squares then p mo d To see

2 2

this write p a b As p is o dd then we may assume that a is

2

even and b is o dd So mo d we have a f g so that a mo d

2

Similarly b f g mo d so that b mo d so p mo d

If p mo d then p is the sum of two squares This implica

tion is much harder The idea is as follows By quadratic recipro city

2 2 2

we know that A mo d p so letting B we have A B

2 2

mo d p ie A B M p If M we are done Otherwise we need

2 2

a pro cedure to nd new integers a b m such that a b mp and

m M We then rep eat this pro cedure until m

This is known as Fermats Descent Pro cedure This is how it works

Let p b e any prime with p mo d eg we may write

2 2 2 2

A B M p with M p eg

1

We may pick u A v B mo d M such that M u v

2

1

2 2 2 2

M eg u v then u v A B mo d M

2

2 2 2 2

We have u v M r and A B M p for some r M

2 2 2 2

eg and

2 2

Notice that r since otherwise u v so u v

2

so A u mo d M and B v mo d M But then M

2 2

divides A B M p so that M divides p But M p so

that this is imp ossible

2 2

2 2

(M 2) +(M 2)

u +v M

Notice that r M since r

M M 2

M

If we multiply these together we get

2 2 2 2 2 2 2

uA v B v A uB u v A B M r p

2 2

Notice that uA v B A B M p mo d M and

v A uB BA AB mo d M So uA v B and

v A uB are divisible by M EguA v B

and v A uB

We have therefore obtained the equation

   

2 2

uA v B v A uB

r p

M M

2 2 2 2

with r M eg Rep eating this

we will get r as required

˜

Exercise Use Fermats descent pro cedure to write as the sum

of squares Do the same for p

Fermats Last Theorem

In the th century Fermat stated that the equation

n n n

a b c

19

has no solutions for n and a b c Rememb er that for n

this equation has innitely many solutions and we can describ e all of

these So this fact is very surprising It also turns out to b e a very

deep result which was eventually proven by Wiles at the end of the

th century We will show the following

n n n

Theorem The equation a b c has no solution when n is

divisible by and a b c

4 4 2

Proof It is enough to show that the equation x y z has no

solution for x y z In fact if a b c is a solution of the original

n4 n4 n2

equation then x a y b and z c are solutions to our

new equation The idea is once again to show that if there is a solution

0 0 0 0

x y z then we can nd a new solution x y z with z z We

cant rep eat this innitely many times so there was no solution to

b egin with

To b egin with notice that we may assume that x y z have no com

2 2

mon factor Now if we let a x b y and c z then a b c is a

primitive Pythagorean triple and so we may write

2 2 2 2

s t s t

2 2

x a st y b z c

2

for some o dd integers s t with no common factor Now st x is an

o dd square so that st mo d It follows that either

s t mo d or s t mo d

Also we have

2 2 2

y s t s ts t

Since s t are o dd and relatively prime then the only common factor

of s t and s t is Now divides s t so s t r where r is an

2

o dd numb er Now y s ts t so we have

2 2

s t u and s t v

where GC D u v Solving for s t we get

2 2 2 2

s u v and t u v

2

and so from the formula x st it follows that

2 4 4 2 4 4

x u v or x v u

2 2

We now let A x B v and C u so that

2 2 2

A B C

and A B C have no common factor ie A B C is a primitive Pythagorean

triplet Therefore we know that there are o dd relatively prime integers

S T such that

2 2 2 2

T S T S

2 2

x A S T v B u C

20

So we get

2 2 2

v S T S T S T

Now GC D S T S T S T are o dd and relatively prime So

we must have

2 2

S T x and S T y so

2 2 2 2

S x y and T x y so

2 2 2 2 2 2 2 2

S T x y x y

2 4 4

u x y

4 4 2

This is the new solution x y u to the original equation x y z

We must still show that u z but this is clear from the formula

2 2 2 2 2 2 2 2

s t u v u v

4 4

z u v

˜

Answers to the exercises

Ex

2

Ex

2

Ex do es not divide but it do es divide

100

Ex To compute the last two digits of we just need

2

to compute the last two digits of various p owers of

4 8 16 32 64 100

64+32+4 111 64+32+16+2+1

Ex mo d mo d mo d

1

mo d do es not exist

2 3 4 8

Mo d we have so

Mo d the p owers of are so the order is

The p owers of are so the order is

The p owers of are so the order is

The p owers of are so the order is

The p owers of are so the order is

The p owers of are so the order is

The p owers of are so the order is

The p owers of are so the order is

The p owers of are so the order is

2

the squares mo d are so x has no solution

2 2

mo d and

Ex

so GC D

21

Ex

and has no divisors We would need to use

a computer we got lucky here

Ex referring to ex

Ex so

so mo d

100

Ex abcd X So d mo d

ie d

c mo d ie c mo d so

that c mo d so that c

b mo d ie b mo d ie

b mo d so b

a mo d ie a mo d

so a mo d so a

10

Ex

So

10

10 1

So

10 10

mo d so SSN mo d

2 4 2 2 2 8 4 2 2

Ex

Since we have

12345 8 1543 1543

2 4 8 16 2

Ex

32 2

So

12345 100 123 45 123 32+8+4+1

3 6

Ex Mo d

4 8

Mo d The order is

5 6

Mo d The order is

6 7 8 9

Mo d

10 11 12

The order is

Ex

Ex

90

Ex mo d is not prime

22

9

Ex Mo d we have so and

9

10 16 4 8 2 16 2

Now

9 7 7

10 100 10 10

Mo d so that

9 4 8

Mo d

16 32 2 58 32+16+8+2

2 6

Ex and l og so ab out

2

doublings

9990

Ex mo d

5 5

Ex Mo d mo d so x x

5

mo d

Mo d and mo d so x

3 67 67 2 4 8 16

x mo d Now

32 64 67

So

Ex WELLDONE note that

and mo d

10 10 9

Ex

10 5 10

41 37 33

Ex s hr s years

4 35 70 2

Ex n mo d

140 2 280 2

mo d mo d mo d and

560 2

mo d So failed the RabinMiller test therefore

it can not b e prime is a RabinMiller witness for the numb er

4 3

Ex and mo d so the order of is The

5 7 1 2 3

other elements of order are has order has order

4 6

has order and has order

2

Ex We square all the residues mo d and we get

2 2 2 2 2 2 2 2 2 2

and

mo d So the answer is yes

Ex Mo d

Mo d

Mo d

Mo d

2

Ex x ax b a x b x ab a so we must show

2

that c ab a but this is clear as a is a ro ot of x b x c

2 2

so a ab c If z is a third ro ot of x b x c mo d p then

z az b a so that p divides z a or it divides z b a

but then z a mo d p or z b a mo d p So these are the only two

ro ots

2 2

Ex are ro ots of x mo d so x x

x x x

Ex QR NR so QR NR NR QR

NR and NR NR QR

0 2 4 6 8

Ex Mo d QR

0 2 4 6 8 10

Mo d QR

23

0 2 4 6 8 10

Mo d QR

12 14

Ex Mo d Mo d

Mo d They are all mo d p

1 1 1 1 1

Ex

3 5 7 11

1 1 1 1 1

17 19 29 31

2 2 2 2 2

Ex

3 5 7 11 13

2 2 2 2 2 2

17 19 23 29 31 37

2 2 2

41 43 47

1 2

Ex and

p p

2 2 2

Ex x x x so is a

square mo d p Equivalently is a square mo d p

2 1

and so no Mo d

97 97

Mo d so no

Mo d so no

44 11 53 9 51 101 49

Ex

53 53 11 11 101 51 51

127 36 91

127 91 91

2 2 2 2 2 2 2 2

Ex

2 2 2 2 2 2

2 2

Ex A B so so M u

2 2

v so uA v B M and v A uB M so