27.3 KB · commit a9602da
In Section 4.1 we studied the concept of divisibility of integers. One important concept based on divisibility is that of a prime number. A prime is an integer greater than 1 that is divisible by only 1 and itself. We will study the distribution of primes and introduce some important conjectures and theorems concerning primes. As we will see, primes are the building blocks of integers. Every positive integer can be uniquely written as the product of primes. Because every positive integer can be factored into primes, the primes can be thought of as the atoms from which all integers are made.
The study of prime numbers has a long and fascinating history dating back to ancient Greece. In the last few decades, number theory, and prime numbers in particular, have found many important applications in computer science. Prime numbers have many special properties that make the study of their properties important in cryptography. For example, finding large primes is essential in modern cryptography. The length of time required to factor large integers into their prime factors is the basis for the strength of some important modern cryptographic systems.
In this section we will also study the greatest common divisor of two integers, as well as the least common multiple of two integers. We will develop an important algorithm for computing greatest common divisors, called the Euclidean algorithm.
Every integer greater than 1 is divisible by at least two integers, because a positive integer is divisible by 1 and by itself. Positive integers that have exactly two different positive integer factors are called primes.
The integer 7 is prime because its only positive factors are 1 and 7, whereas the integer 9 is composite because it is divisible by 3. ◀
The primes are the building blocks of positive integers, as the fundamental theorem of arithmetic shows. The proof will be given in Section 5.2.
Example 2 gives some prime factorizations of integers.
The prime factorizations of 100, 641, 999, and 1024 are given by
1006419991024=2⋅2⋅5⋅5=22⋅52,=641,=3⋅3⋅3⋅37=33⋅37,=2⋅2⋅2⋅2⋅2⋅2⋅2⋅2⋅2⋅2=210.◀
It is often important to show that a given integer is prime. For instance, in cryptology, large primes are used in some methods for making messages secret. One procedure for showing that an integer is prime is based on the following observation.
Proof: If n is composite, by the definition of a composite integer, we know that it has a factor a with 1<a<n. Hence, by the definition of a factor of a positive integer, we have n=ab, where b is a positive integer greater than 1. We will show that a≤n or b≤n. If a>n and b>n, then ab>n⋅n=n, which is a contradiction. Consequently, a≤n or b≤n. Because both a and b are divisors of n, we see that n has a positive divisor not exceeding n. This divisor is either prime or, by the fundamental theorem of arithmetic, has a prime divisor less than itself. In either case, n has a prime divisor less than or equal to n. ■
From Theorem 2, it follows that an integer is prime if it is not divisible by any prime less than or equal to its square root. This leads to the brute-force algorithm known as trial division. To use trial division we divide n by all primes not exceeding n and conclude that n is prime if it is not divisible by any of these primes. In Example 3 we use trial division to show that 101 is prime.
Show that 101 is prime.
Solution: The only primes not exceeding 101 are 2, 3, 5, and 7. Because 101 is not divisible by 2, 3, 5, or 7 (the quotient of 101 and each of these integers is not an integer), it follows that 101 is prime. ◀
Because every integer has a prime factorization, it would be useful to have a procedure for finding this prime factorization. Consider the problem of finding the prime factorization of n. Begin by dividing n by successive primes, starting with the smallest prime, 2. If n has a prime factor, then by Theorem 2 a prime factor p not exceeding n will be found. So, if no prime
factor not exceeding n is found, then n is prime. Otherwise, if a prime factor p is found, continue by factoring n/p. Note that n/p has no prime factors less than p. Again, if n/p has no prime factor greater than or equal to p and not exceeding its square root, then it is prime. Otherwise, if it has a prime factor q, continue by factoring n/(pq). This procedure is continued until the factorization has been reduced to a prime. This procedure is illustrated in Example 4.
Find the prime factorization of 7007.
Solution: To find the prime factorization of 7007, first perform divisions of 7007 by successive primes, beginning with 2. None of the primes 2, 3, and 5 divides 7007. However, 7 divides 7007, with 7007/7=1001. Next, divide 1001 by successive primes, beginning with 7. It is immediately seen that 7 also divides 1001, because 1001/7=143. Continue by dividing 143 by successive primes, beginning with 7. Although 7 does not divide 143, 11 does divide 143, and 143/11=13. Because 13 is prime, the procedure is completed. It follows that 7007=7⋅1001=7⋅7⋅143=7⋅7⋅11⋅13. Consequently, the prime factorization of 7007 is 7⋅7⋅11⋅13=72⋅11⋅13. ◀
Prime numbers were studied in ancient times for philosophical reasons. Today, there are highly practical reasons for their study. In particular, large primes play a crucial role in cryptography, as we will see in Section 4.6.
Note that composite integers not exceeding 100 must have a prime factor not exceeding 10. Because the only primes less than 10 are 2, 3, 5, and 7, the primes not exceeding 100 are these four primes and those positive integers greater than 1 and not exceeding 100 that are divisible by none of 2, 3, 5, or 7.
The sieve of Eratosthenes is used to find all primes not exceeding a specified positive integer. For instance, the following procedure is used to find the primes not exceeding 100. We begin with the list of all integers between 1 and 100. To begin the sieving process, the integers that are divisible by 2, other than 2, are deleted. Because 3 is the first integer greater than 2 that is left, all those integers divisible by 3, other than 3, are deleted. Because 5 is the next integer left after 3, those integers divisible by 5, other than 5, are deleted. The next integer left is 7, so those integers divisible by 7, other than 7, are deleted. Because all composite integers not exceeding 100 are divisible by 2, 3, 5, or 7, all remaining integers except 1 are prime.
| Integers divisible by 2 (except 2) deleted | Integers divisible by 3 (except 3) deleted | Integers divisible by 5 (except 5) deleted | Integers divisible by 7 (except 7) deleted; Primes remain |
|---|---|---|---|
| 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ... | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ... | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ... | 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 |
We conclude that the primes less than 100 are: 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97.
It has long been known that there are infinitely many primes. This means that whenever p1,p2,…,pn are the n smallest primes, we know there is a larger prime not listed. We will prove this fact using a proof given by Euclid in his famous mathematics text, The Elements.
Proof: We will prove this theorem using a proof by contradiction. We assume that there are only finitely many primes, p1,p2,…,pn. Let Q=p1p2…pn+1. By the fundamental theorem of arithmetic, Q is prime or else it can be written as the product of two or more primes. However, none of the primes pj divides Q, for if pj∣Q, then pj divides
Q−p1p2…pn=1. Hence, there is a prime not in the list p1,p2,…,pn. This prime is either Q, if it is prime, or a prime factor of Q. This is a contradiction because we assumed that we have listed all the primes. Consequently, there are infinitely many primes. ■
Because there are infinitely many primes, given any positive integer there are primes greater than this integer. There is an ongoing quest to discover larger and larger prime numbers; for almost all the last 300 years, the largest prime known has been an integer of the special form 2p−1, where p is also prime. Such primes are called Mersenne primes, after the French monk Marin Mersenne. The reason that the largest known prime has usually been a Mersenne prime is that there is an extremely efficient test, known as the Lucas–Lehmer test, for determining whether 2p−1 is prime.
The numbers 22−1=3,23−1=7,25−1=31, and 27−1=127 are Mersenne primes, while 211−1=2047 is not a Mersenne prime because 2047=23⋅89. ◀
Progress in finding Mersenne primes has been steady since computers were invented. A communal effort, the Great Internet Mersenne Prime Search (GIMPS), is devoted to the search for new Mersenne primes.
Theorem 3 tells us that there are infinitely many primes. However, how many primes are less than a positive number x?
We can use the prime number theorem to estimate the odds that a randomly chosen number is prime. The prime number theorem tells us that the number of primes not exceeding x can be approximated by x/lnx. Consequently, the odds that a randomly selected positive integer less than n is prime are approximately (n/lnn)/n=1/lnn.
Using trial division with Theorem 2 gives procedures for factoring and for primality testing. However, these procedures are not efficient algorithms. In 2002, an important theoretical discovery was made by Manindra Agrawal, Neeraj Kayal, and Nitin Saxena. They showed there is a polynomial-time algorithm in the number of bits in the binary expansion of an integer for determining whether a positive integer is prime. Algorithms based on their work use O((logn)6) bit operations to determine whether a positive integer n is prime.
However, factoring large numbers remains extraordinarily more time-consuming than primality testing. No polynomial-time algorithm for factoring integers is known.
Every odd integer is in one of the two arithmetic progressions 4k+1 or 4k+3,k=1,2,…. Dirichlet proved that every arithmetic progression ak+b,k=1,2,…, where no integer greater than one divides both a and b, contains infinitely many primes.
In 2006, Ben Green and Terence Tao proved the Green-Tao theorem: for every positive integer n greater than two, there is an arithmetic progression of length n made up entirely of primes.
Number theory is noted as a subject for which it is easy to formulate conjectures, some of which are difficult to prove and others that remained open problems for many years.
It would be useful to have a function f(n) such that f(n) is prime for all positive integers n. After a lot of computation we may encounter the polynomial f(n)=n2−n+41. This polynomial has the interesting property that f(n) is prime for all positive integers n not exceeding 40. Can we settle the conjecture that f(n) is prime for all positive integers n?
Solution: This conjecture turns out to be false; we do not have to look far to find a positive integer n for which f(n) is composite, because f(41)=412−41+41=412.
It can be shown that for every polynomial f(n) with integer coefficients, there is a positive integer y such that f(y) is composite. ◀
Goldbach's conjecture asserts that every even integer n,n>2, is the sum of two primes. For example, 4=2+2,6=3+3,8=5+3,10=7+3,12=7+5, and so on. Goldbach's conjecture has been verified for all positive even integers up to 1.6⋅1018. Although no proof has been found, most mathematicians believe it is true. ◀
A conjecture asserting that there are infinitely many primes of certain special forms is the conjecture that there are infinitely many primes of the form n2+1, where n is a positive integer. For example, 5=22+1,17=42+1,37=62+1, and so on. The best result currently known is that there are infinitely many positive integers n such that n2+1 is prime or the product of at most two primes (proved by Henryk Iwaniec in 1973). ◀
Twin primes are pairs of primes that differ by 2, such as 3 and 5, 5 and 7, 11 and 13, 17 and 19, and 4967 and 4969. The twin prime conjecture asserts that there are infinitely many twin primes. ◀
The largest integer that divides both of two integers is called the greatest common divisor of these integers.
What is the greatest common divisor of 24 and 36?
Solution: The positive common divisors of 24 and 36 are 1, 2, 3, 4, 6, and 12. Hence, gcd(24,36)=12. ◀
What is the greatest common divisor of 17 and 22?
Solution: The integers 17 and 22 have no positive common divisors other than 1, so that gcd(17,22)=1. ◀
By Example 11 it follows that the integers 17 and 22 are relatively prime, because gcd(17,22)=1. ◀
Determine whether the integers 10, 17, and 21 are pairwise relatively prime and whether the integers 10, 19, and 24 are pairwise relatively prime.
Solution: Because gcd(10,17)=1,gcd(10,21)=1, and gcd(17,21)=1, we conclude that 10, 17, and 21 are pairwise relatively prime.
Because gcd(10,24)=2>1, we see that 10, 19, and 24 are not pairwise relatively prime. ◀
Another way to find the greatest common divisor of two positive integers is to use the prime factorizations of these integers. Suppose that the prime factorizations of the positive integers a and b are a=p1a1p2a2…pnan,b=p1b1p2b2…pnbn, where each exponent is a nonnegative integer, and where all primes occurring in the prime factorization of either a or b are included in both factorizations, with zero exponents if necessary. Then gcd(a,b) is given by gcd(a,b)=p1min(a1,b1)p2min(a2,b2)…pnmin(an,bn), where min(x,y) represents the minimum of the two numbers x and y.
Because the prime factorizations of 120 and 500 are 120=23⋅3⋅5 and 500=22⋅53, the greatest common divisor is gcd(120,500)=2min(3,2)3min(1,0)5min(1,3)=22⋅30⋅51=20. ◀
Prime factorizations can also be used to find the least common multiple of two integers.
Suppose that the prime factorizations of a and b are as before. Then the least common multiple of a and b is given by lcm(a,b)=p1max(a1,b1)p2max(a2,b2)…pnmax(an,bn), where max(x,y) denotes the maximum of the two numbers x and y.
What is the least common multiple of 233572 and 2433?
Solution: We have lcm(233572,2433)=2max(3,4)3max(5,3)7max(2,0)=243572. ◀
Computing the greatest common divisor of two integers directly from the prime factorizations of these integers is inefficient. The reason is that it is time-consuming to find prime factorizations. We will give a more efficient method of finding the greatest common divisor, called the Euclidean algorithm.
Before describing the Euclidean algorithm, we will show how it is used to find gcd(91,287). First, divide 287, the larger of the two integers, by 91, the smaller, to obtain 287=91⋅3+14. Any divisor of 91 and 287 must also be a divisor of 287−91⋅3=14. Also, any divisor of 91 and 14 must also be a divisor of 287=91⋅3+14. Hence, the greatest common divisor of 91 and 287 is the same as the greatest common divisor of 91 and 14. This means that the problem of finding gcd(91,287) has been reduced to the problem of finding gcd(91,14).
Next, divide 91 by 14 to obtain 91=14⋅6+7. Because any common divisor of 91 and 14 also divides 91−14⋅6=7 and any common divisor of 14 and 7 divides 91, it follows that gcd(91,14)=gcd(14,7).
Continue by dividing 14 by 7, to obtain 14=7⋅2. Because 7 divides 14, it follows that gcd(14,7)=7. Furthermore, because gcd(287,91)=gcd(91,14)=gcd(14,7)=7, the original problem has been solved.
Proof: If we can show that the common divisors of a and b are the same as the common divisors of b and r, we will have shown that gcd(a,b)=gcd(b,r), because both pairs must have the same greatest common divisor.
So suppose that d divides both a and b. Then it follows that d also divides a−bq=r (from Theorem 1 of Section 4.1). Hence, any common divisor of a and b is also a common divisor of b and r.
Likewise, suppose that d divides both b and r. Then d also divides bq+r=a. Hence, any common divisor of b and r is also a common divisor of a and b.
Consequently, gcd(a,b)=gcd(b,r). ■
Suppose that a and b are positive integers with a≥b. Let r0=a and r1=b. When we successively apply the division algorithm, we obtain
r0r1rn−2rn−1=r1q1+r2,=r2q2+r3, ⋮=rn−1qn−1+rn,=rnqn.0≤r2<r1,0≤r3<r2,0≤rn<rn−1,Eventually a remainder of zero occurs in this sequence of successive divisions, because the sequence of remainders a=r0>r1>r2>⋯≥0 cannot contain more than a terms. Furthermore, it follows from Lemma 1 that gcd(a,b)=gcd(r0,r1)=gcd(r1,r2)=⋯=gcd(rn−2,rn−1)=gcd(rn−1,rn)=gcd(rn,0)=rn. Hence, the greatest common divisor is the last nonzero remainder in the sequence of divisions.
Find the greatest common divisor of 414 and 662 using the Euclidean algorithm.
Solution: Successive uses of the division algorithm give:
66241424816682=414⋅1+248=248⋅1+166=166⋅1+82=82⋅2+2=2⋅41.Hence, gcd(414,662)=2, because 2 is the last nonzero remainder. ◀
The Euclidean algorithm is expressed in pseudocode in Algorithm 1.
In Algorithm 1, the initial values of x and y are a and b, respectively. At each stage of the procedure, x is replaced by y, and y is replaced by xmody, which is the remainder when x is divided by y. This process is repeated as long as y=0. The algorithm terminates when y=0, and the value of x at that point, the last nonzero remainder in the procedure, is the greatest common divisor of a and b.
The number of divisions required to find the greatest common divisor of a and b, where a≥b, is O(logb).
An important result we will use throughout the remainder of this section is that the greatest common divisor of two integers a and b can be expressed in the form sa+tb, where s and t are integers. In other words, gcd(a,b) can be expressed as a linear combination with integer coefficients of a and b. For example, gcd(6,14)=2, and 2=(−2)⋅6+1⋅14. We state this fact as Theorem 6.
The method proceeds by working backward through the divisions of the Euclidean algorithm, requiring a forward pass and a backward pass through the steps of the Euclidean algorithm.
Express gcd(252,198)=18 as a linear combination of 252 and 198.
Solution: To show that gcd(252,198)=18, the Euclidean algorithm uses these divisions:
2521985436=1⋅198+54=3⋅54+36=1⋅36+18=2⋅18.Using the next-to-last division (the third division), we can express gcd(252,198)=18 as a linear combination of 54 and 36: 18=54−1⋅36. The second division tells us that 36=198−3⋅54. Substituting this expression for 36 into the previous equation, we can express 18 as a linear combination of 54 and 198: 18=54−1⋅(198−3⋅54)=4⋅54−1⋅198. The first division tells us that 54=252−1⋅198. Substituting this expression for 54 into the previous equation, we can express 18 as a linear combination of 252 and 198: 18=4⋅(252−1⋅198)−1⋅198=4⋅252−5⋅198. ◀
We will use Theorem 6 to develop several useful results.
Proof: Because gcd(a,b)=1, by Bézout's theorem there are integers s and t such that sa+tb=1. Multiplying both sides of this equation by c, we obtain sac+tbc=c. We can now use Theorem 1 of Section 4.1 to show that a∣c. By part (ii) of that theorem, a∣tbc. Because a∣sac and a∣tbc, by part (i) of that theorem, we conclude that a divides sac+tbc. Because sac+tbc=c, we conclude that a∣c, completing the proof. ■
We can now show that a factorization of an integer into primes is unique.
We will use a proof by contradiction. Suppose that the positive integer n can be written as the product of primes in two different ways, say, n=p1p2…ps and n=q1q2…qt, where each pi and qj are primes such that p1≤p2≤⋯≤ps and q1≤q2≤⋯≤qt.
When we remove all common primes from the two factorizations, we have pi1pi2…piu=qj1qj2…qjv, where no prime occurs on both sides of this equation and u and v are positive integers. By Lemma 3 it follows that pi1 divides qjk for some k. Because no prime divides another prime, this is impossible. Consequently, there can be at most one factorization of n into primes in nondecreasing order. ■
Lemma 2 can also be used to prove a result about dividing both sides of a congruence by the same integer.
The congruence 14≡8(mod6) holds, but both sides of this congruence cannot be divided by 2 to produce a valid congruence because 14/2=7 and 8/2=4, but 7≡4(mod6). ◀
Although we cannot divide both sides of a congruence by any integer to produce a valid congruence, we can if this integer is relatively prime to the modulus. Theorem 7 establishes this important fact.
Proof: Because ac≡bc(modm), m∣ac−bc=c(a−b). By Lemma 2, because gcd(c,m)=1, it follows that m∣a−b. We conclude that a≡b(modm). ■