Every whole number greater than can be broken into primes, and the real question is whether it can be broken in only one way.
The previous lesson ran Euclid's algorithm backwards to get Bézout's identity: for integers and , not both zero, there are integers and with . This lesson proves Euclid's lemma from Bézout, uses it to prove that factorisation into primes is unique, then turns to finding primes and counting them.
Primes, and why every number has one
An integer is prime if its only positive divisors are and , and an integer that is not prime is composite, a product with . The number is neither: if it counted as prime, would already be two factorisations.
Every integer has a prime divisor, because its smallest divisor is prime: a divisor of with would divide too, contradicting the choice of . So the least divisor of above is , which is prime, and .
That fact carries Euclid's proof that the primes never run out, recalled here from Proof and Logic rather than taught again: for any finite list of primes, their product plus leaves remainder on division by each, so its prime divisor is missing from the list. The proof, in Book IX of Euclid's Elements around 300 BC, says nothing about how the primes are spread out, a question the end of this lesson takes up.
Euclid's lemma
Euclid's lemma says: if is prime and , then or . (Here reads " divides ".) Composite numbers fail it: , yet divides neither nor , because the factors and of went to different places.
The proof is short. Suppose and does not divide . The only positive divisors of are and , so . Bézout's identity gives integers and with
Multiply through by to get . The first term is a multiple of , and so is the second, since . So divides their sum, which is .
The lemma extends to any number of factors by induction: if , write the product as , and either or divides the shorter product. In particular, if a prime divides a product of primes , it divides some , and since the only divisor of above is itself, .
Example. Prove that is irrational.
Suppose with and positive integers sharing no common factor. Squaring gives , so , and Euclid's lemma gives . Write ; then , so , and the same step gives . Now divides both, contradicting lowest terms. The proof for in Proof and Logic used parity at this step; Euclid's lemma works for every prime.
Now you. Prove that is irrational.
Answer
Suppose in lowest terms, so . Then , so by Euclid's lemma. Writing gives , that is . So , and since does not divide the lemma gives and then . Both and are multiples of , a contradiction.
The fundamental theorem of arithmetic
Theorem. Every integer is a product of primes, and this product is unique apart from the order of the factors.
Existence is proved by strong induction, where the hypothesis covers every smaller case at once. The number is prime. Take and assume every integer from to is a product of primes. If is prime there is nothing to do. Otherwise with , both and are products of primes by hypothesis, and writing one list after the other expresses . Ordinary induction would not do, since and can be anywhere below .
Uniqueness is where Euclid's lemma enters. Suppose
with every and prime, and argue by induction on . The prime divides the right side, so by the extended lemma for some . Reorder so that this one is and cancel it, leaving , a shorter equation of the same kind. By the inductive hypothesis its sides are the same primes in some order, and so were the originals. (When , cancelling leaves , which forces .)
Collecting repeated primes gives the standard form with and every exponent at least , so . Two numbers are equal exactly when their standard forms agree, which is the sense in which the primes are the atoms of the integers. Euclid had the lemma, but the first clear statement and proof of the whole theorem is in Gauss's Disquisitiones Arithmeticae of 1801.
Why uniqueness is not obvious
Uniqueness can feel too obvious to need proof, since factorising by any route ends at the same primes. To see that it is a real theorem, look at a system where the existence proof works word for word and uniqueness fails.
Take the even numbers and call one "prime" there if it is not a product of two even numbers. Such a product is a multiple of , so the primes of this system are , the even numbers that are not multiples of . The strong induction goes through unchanged, so every even number is a product of these primes. But
and , and are all prime in . What failed is Euclid's lemma: divides in this system, yet divides neither nor , because and is not in the system. And the lemma failed because its proof did: has no , so no Bézout combination can equal .
The same thing happens in systems mathematicians needed. Among the numbers with and integers, , and none of those four factors splits further. In 1847 Gabriel Lamé announced a proof of Fermat's last theorem that quietly assumed unique factorisation in a system of this kind, and it emerged that Ernst Kummer had already shown in 1844 that it can fail there. For the ordinary integers the theorem holds, and the reason is the division algorithm, through Euclid's algorithm and Bézout.
Computing with factorisations
In standard form, divisibility becomes a comparison of exponents. If , then exactly when with for every . Conversely, if , the standard forms of and together factorise , so by uniqueness no prime appears in more often than in .
Each divisor is then a choice of exponent for each prime, options for , so by the product rule the number of positive divisors is
For the gcd and lcm, write both numbers over the same primes, allowing exponent . A common divisor may take at most the smaller exponent of each prime and a common multiple needs at least the larger, so the gcd takes minimum exponents and the lcm maximum ones. Since , this proves .
For large numbers Euclid's algorithm is far faster, since nobody knows a fast way to factorise, a gap a later lesson on RSA turns into a lock. By hand, the standard forms show everything at once.
Example. Find the number of divisors of , and and .
Factorise: and . So . Over the primes the exponents are and . Minimums give , and maximums give . Check: .
Now you. Find the number of divisors of , and and .
Answer
and . So . The exponents over are and , giving and , and .
The sieve of Eratosthenes
To list the primes up to a bound, the method credited to Eratosthenes of Cyrene, the third century BC scholar who also measured the Earth, crosses out composites instead of testing each number. Write out . The first number, , is prime; cross out its multiples. The next survivor, , is prime, since no smaller prime divides it; cross out its multiples. Each number that survives to its turn is prime, and its multiples go.
The sieve can stop early. If is composite with , then , so : every composite up to has a prime factor no bigger than . Once the primes up to have been used, every composite is gone. For the same reason the pass for can start at : smaller multiples of have a smaller prime factor too.
Run to , the sieve needs only , , and . The pass for crosses out the even numbers from to ; the pass for removes new ones, the odd multiples of from to ; the pass for removes only ; and the pass for only . That is composites out of the numbers from to , leaving the primes.
Example. Find the primes between and .
Since , only are needed. The pass for leaves the fifteen odd numbers . The pass for removes ; the pass for removes and ; the pass for removes ; and the pass for removes . The survivors are and , six primes.
Now you. Find the primes between and .
Answer
, so sieve with . Of the odd numbers from to , the pass for removes , the pass for removes and , the pass for removes , and the pass for removes . The primes are .
How the primes thin out
Up to a quarter of the numbers are prime, from to only twelve of sixty. Write for the number of primes up to (a name here, unrelated to ). A computer sieve gives the counts below, set against , with the natural logarithm.
| ratio | |||
|---|---|---|---|
| 100 | 25 | 21.7 | 1.151 |
| 1,000 | 168 | 144.8 | 1.161 |
| 10,000 | 1,229 | 1,085.7 | 1.132 |
| 1,000,000 | 78,498 | 72,382.4 | 1.084 |
| 1,000,000,000 | 50,847,534 | 48,254,942.4 | 1.054 |
The ratio drifts down towards , slowly. Carl Friedrich Gauss noticed the pattern in tables of primes around 1792, aged fifteen, and Adrien-Marie Legendre published a similar formula in 1798, but neither could prove it. In 1896 Jacques Hadamard and Charles de la Vallée Poussin, independently, proved the prime number theorem:
Both proofs used complex analysis, building on Bernhard Riemann's 1859 work on the zeta function. The theorem has a plain reading: near , roughly one number in is prime. Near a million that is one in , near a billion one in . Up to a billion the average gap between primes is , just under , the same slow convergence as in the table.
Locally the primes are irregular. Gaps can be as long as desired: for the numbers are all composite, since divides for each from to . Yet primes two apart, like and , keep appearing, and whether they do forever is unknown.
Divisibility is a question about remainders
Everything in this lesson has asked whether one number divides another, and that is a question about a remainder: exactly when dividing by leaves remainder . The remainder of a product depends only on the remainders of its factors. Numbers leaving remainders and on division by are and , and their product is , which leaves the same remainder as , namely .
In that language Euclid's lemma says: if neither nor leaves remainder on division by a prime , neither does . Nonzero remainders multiply without ever producing . For a composite divisor this fails, since leaves remainder on division by : a divisor of a product that divides neither factor, as was in . So the natural setting for divisibility is the remainders themselves, and the next lesson makes them into a number system with its own addition and multiplication, where some elements have inverses and equations can be solved.