Homepage › Solution manuals › Ivan Niven › An Introduction to the Theory of Numbers › Exercise 2.4.2 (Fast exponentiation)
Exercise 2.4.2 (Fast exponentiation)
Show that . Deduce that is composite.
Answers
Proof.
- a)
-
The algorithm of fast exponentiation described page 77 gives the following intermediate results
where, at the beginning
and at each step of the loop,
At the end, .
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
If was prime, we would obtain . Therefore is composite
2024-08-21 14:15