Exercise 2.4.2 (Fast exponentiation)

Show that 2 45 57 ( mod 91 ) . Deduce that 91 is composite.

Answers

Proof.

a)
The algorithm of fast exponentiation described page 77 gives the following intermediate results a n n mod 2 result 2 45 1 2 4 22 0 2 16 11 1 32 74 5 1 2 16 2 0 2 74 1 1 57

where, at the beginning

a 2 , result 1 ,

and at each step of the loop,

result a result mod p ( if  n  mod  2 = 0 ) , a ( a a ) mod p n n 2 if  n = 0 : stop .

At the end, result = a n ( mod p ) .

Python:

     def powermod(a,n,p):
         result = 1
         while n!= 0:
             if n % 2 != 0:
                 result = (a * result) % p
             a = (a * a) % p
             n = n // 2
         return result

b)
By part (a), we obtain 2 45 57 ± 1 ( mod 91 ) .

If n = 91 was prime, we would obtain 2 ( n 1 ) 2 ± 1 ( mod n ) . Therefore 91 is composite

User profile picture
2024-08-21 14:15
Comments