Pseudoprimes
Roland Engdahl University of Kalmar Sweden mr.engdahl@telia.com
Introduction
In order to prove primality of a number, previously we required a list of primes. Eratosthenes, about 230 B.C., created his famous sieve, The Sieve of Eratosthenes. Nowadays we have methods to perform sieve and store a table of primes on a computer system.
Fermat, 1640 , described one characteristic of primes in his famous theorem. The converse of this theorem is however not true. There are composite numbers which comply with this characteristic These numbers are called pseudoprimes.
This application provides examples and programs about primes, pseudoprimes, Carmichael numbers, strong pseudoprimes and primality testing. Only definitions of the concepts are included.
Proofs and deeper studies in the theory are to be found in books on number theory e g Kumanduri and Romero, Number theory with computer applications.
A new paradigm in mathematics is experimenting. Consult these sources: Borwein and Bailey and Girgensohn, (vol 1) Mathematics by Experiment, Plausible Reasoning in the 21 st Century, 2004. (vol 2) Experimentation in Mathematics, Computational Paths to Discovery, 2004.
Perhaps experiments with these programs will increase the esteem of number theory.
Fermat's Theorem
If p is prime then
Example
5 is a prime. Divide
To calculate
a&^b mod n calculates
Example in Maple
97 is a prime Calculate
Solution
Issue 341
Calculate
Comments
From the example above we see that the conversion of Fermat's theorem is false.
341 has a characteristic for a prime but is composite
341 is called a pseudoprime to base 2
Definition of pseudoprime and Maple example
A composite number n is called a pseudoprime to base a if
Compare the number of primes and the number of pseudoprimes to a given base
Program
The test shows that pseudoprimes are rather common. It is not a very good idea to use pseudoprimes for primality testing
Issue 561
Program for examination of bases for which 561 is a pseudoprime
n psp base 2 n psp base 5 n psp base 7 n psp base 13 n psp base 19 n psp base 23
Result from the examination
561 is a pseudoprime to all bases a with (561,a)=1 561=3·11·17. Therefore the numbers 3,9,11,15,17,21 are excluded from the bases 561 is an example of Carmichael number: See next section
Carmichael numbers
Definition
A composite number n is called a Carmichael number if
Theorem
A composite number n is a Carmichael number if and only if for every prime divisor p to n we have p-1 is divisor to n-1
Programs to calculate Carmichael numbers
Program with 3 factors
Program with 4 factors
Strong pseudoprimes
Definition Given an odd composite integer n with n - 1 = q· n is a strong pseudorprime to base a if = 1 mod n or Strong pseudoprimes are introduced to get a better tool for identifying probable primes
Applications strong pseudoprimes
Testing strong pseudoprimes to different bases
try numbers n 314821 873181 76491 597871 112141 87913 12403
try bases a 2 3 5 7 11 13
Compare the number of pseudoprimes and strong pseudoprimes
Test for pseudoprime and strongpseudoprime with bases in a testbase
n strong pseudoprime base 2 n pseudoprime base 3 n pseudoprime base 5 n strong pseudoprime base 7 n pseudoprime base 11 n pseudoprime base 17
Primality test: testing n for strong pseudoprimes to several bases in testbase
n spp base 2 n spp base 3 n spp base 5 n spp base 7 n spp base 11 n spp base 13 n spp base 17 n spp base 19 n spp base 23 n spp base 29
The program above admits us to test a number n for strong pseudoprimality (spp-test) to several bases. For simplicity the testbase was given. (Theoretically it is possible to construct a composite number which pass the spp-test for any small set of bases a.) If n is prime then it satisfies spp-test to all bases a. Rabin has showed that:: if n is composite and we select base a at random the probability that n passes the spp-test to base a is less than1/4. If we repeat the test t times with different a and n passes the spp-test the probability that n is prime is . We call n a probable prime. (Miller-Rabin Probabilistic Primality Test) If n passes the spp-test to 10 bases the probability that n is prime is 0.999999. Most numbers are composite and the spp-test will prove their compositeness. The spp-test will never prove the primality, only that the number is a probable prime. There are a number of more advanced probabilty tests. Probabilistic primality tests are sufficient for practical use e g cryptography.
Conclusion
As you have discovered from the programs, MAPLE is well suited for (among others) applications like these.
Some results
Examples for the treated types of pseudoprimes
p primes p(x) primes less than x pp pseudoprime pseudoprime to base a spp strong pseudoprime Cmn Carmichael number
Cmn(x) Carmichael number less than x
?a : Least element in each region p 2 341 2047 Cmn 561 Cmn? 15841 Number of elements x = p(x) 78498 245 46 Cmn(x) 43 (of these 23 with 3 factors, 19 with 4 factors, 1 with 5 factors)
'Beautiful' Carmichael numbers
1729 = 7*13*19 = 19*91 = + 41041 = 7*11*13*41 = 1001*41 410041= 41*73*137 = 10001*41 101101 = 7*11*13*101 = 101*1001
Legal Notice: The copyright for this application is owned by the author(s). Neither Maplesoft nor the author are responsible for any errors contained within and are not liable for any damages resulting from the use of this material. This application is intended for non-commercial, non-profit use only. Contact the author for permission if you wish to use this application in for-profit activities.