# On the other hand consider the case of m 63 note that

• 129

This preview shows page 106 - 109 out of 129 pages.

On the other hand , consider the case of m = 63. Note that 2 6 = 64 1 (mod 63) . Hence, 2 6 1 (mod 63). Raising both sides to the 10th power we have 2 60 1 (mod 63) . Then multiplying both sides by 2 2 we get 2 62 4 (mod 63) since 4 1 (mod 63) we have 2 62 1 (mod 63) . This tells us that 63 is not prime, without factoring 63. We emphasize that in general if 2 m - 1 1 (mod m ) then we can be sure that m is not prime. FACT. There are 455,052,511 odd primes p 10 10 , all of which satisfy 2 p - 1 1 (mod p ). There are only 14,884 composite numbers 2 < m 10 10 that satisfy 2 m - 1 1 (mod m ). Thus, if 2 < m 10 10 and m satisfies 2 m - 1 1 (mod m ), the probability m is prime is 455 , 052 , 511 455 , 052 , 511 + 14 , 884 . 999967292 . In other words, if you find that 2 m - 1 1 (mod m ), then it is highly likely (but not a certainty) that m is prime, at least when m 10 10 . Thus the following Maple procedure will almost always give the correct answer: > is_prob_prime:=proc(n) if n <=1 or Power(2,n-1) mod n <> 1 then return "not prime"; else return "probably prime"; end if; end proc:
99 Note that the Maple command Power(a,n-1) mod n is an efficient way to compute a n - 1 mod n . We discuss this in more detail later. The procedure is_prob_prime(n) just defined returns “probably prime” if 2 n - 1 mod n = 1 and “not prime” if n 1 or if 2 n - 1 mod n = 1. If the answer is “not prime”, then we know definitely that n is not prime. If the answer is “probably prime”, we know that there is a very small probability that n is not prime. In practice, there are better probabilistic primality tests than that men- tioned above. For more details see, for example, “Elementary Number The- ory,” Fourth Edition, by Kenneth Rosen. The built-in Maple procedure isprime is a very sophisticated probabilis- tic primality test. The command isprime(n) returns false if n is not prime and returns true if n is probably prime. So far no one has found an integer n for which isprime(n) gives the wrong answer. One might ask what happens if we use 3 instead of 2 in the above prob- abilistic primality test. Or, better yet, what if we evaluate a m - 1 mod m for several different values of a . Consider the following data: The number of primes 10 6 is 78,498. The number of composite numbers m 10 6 such that 2 m - 1 1 (mod m ) is 245. The number of composite numbers m 10 6 such that 2 m - 1 1 (mod m ) and 3 m - 1 1 (mod m ) is 66. The number of composite numbers m 10 6 such that a m - 1 1 (mod m ) for a ∈ { 2 , 3 , 5 , 7 , 11 , 13 , 17 , 19 , 31 , 37 , 41 } is 0. Thus, we have the following result: If m 10 6 and a m - 1 1 (mod m ) for a ∈ { 2 , 3 , 5 , 7 , 11 , 17 , 19 , 31 , 37 , 41 } , then m is prime. The above results for m 10 6 were found using Maple. If m > 10 6 and a m - 1 1 (mod m ) for a ∈ { 2 , 3 , 5 , 7 , 11 , 17 , 19 , 31 , 37 , 41 } , it is highly likely, but not certain, that m is prime. Actually the primality test isprime that is built into Maple uses a somewhat different idea. Exercise 24.2. Use Maple to show that
100 CHAPTER 24. PROBABILISTIC PRIMALITY TESTS (1) 3 90 1 (mod 91), but 91 is not prime.