๐ Key idea of this section
If n is composite, some prime โค โn divides it. So the test list ends where pยฒ > n โ and we can PROVE why.
Quick refresher: a prime number has exactly two factors, 1 and itself (7 = 1 ร 7 and nothing else). A composite number has more (12 = 3 ร 4). The number 1 is neither โ it has only one factor โ and 2 is the only even prime, since every other even number already has 2 as a factor.
The trap composites still lurk, and they've recruited bigger friends: 91 = 7 ร 13, 119 = 7 ร 17, 133 = 7 ร 19, 161 = 7 ร 23, 187 = 11 ร 17, 221 = 13 ร 17. Every one of them looks prime. Guessers get caught โ detectives prove.
The key theorem: a composite number can't hide its factors past โn
Recall that โn (the square root of n) is the number that multiplies by itself to give n: โ81 = 9 because 9 ร 9 = 81. Now the claim.
Claim: if n is composite, then some prime p โค โn divides n.
Proof, with every step earning its place:
- 1.n is composite, so n = a ร b with 1 < a โค b. (That's the definition of composite; call the smaller partner a.)
- 2.Suppose โ just to see what happens โ that a > โn. Then b โฅ a > โn as well, since b is the bigger partner.
- 3.Multiplying the inequalities: a ร b > โn ร โn = n. Two factors each bigger than โn must multiply to more than n.
- 4.But a ร b = n exactly. Step 3 says a ร b > n and step 1 says a ร b = n โ contradiction! Our supposition in step 2 is impossible, so a โค โn.
- 5.Now, the smallest factor of n that's bigger than 1 is always prime. Why? If it split into smaller pieces, one piece would be an even SMALLER factor of n โ contradicting "smallest." Apply this to a: some prime p โค a divides a, and anything dividing a also divides n = a ร b.
- 6.Conclusion: p โค a โค โn, and p divides n. That finishes the proof. โ
That little square โ is the mathematician's "ta-da, proof complete" symbol. And here is the flip side of the theorem, which is the entire prime test: if NO prime โค โn divides n, then n cannot be composite โ so n is prime.
How far must you check?
- ยทn < 100: โn < 10 (because 10 ร 10 = 100), so checking 2, 3, 5, 7 is enough โ the next prime, 11, already has 11ยฒ = 121 > 99.
- ยทn < 289: the next prime past 13 is 17, and 17ยฒ = 289. So for any number under 289, checking 2, 3, 5, 7, 11, 13 settles it. (13ยฒ = 169, which is why 13 makes the list.)
Worked example: is 199 prime? First estimate the root: 14ยฒ = 196 and 15ยฒ = 225, so โ199 is between 14 and 15. We check primes up through 13.
- ยทBy 2? 199 is odd. No.
- ยทBy 3? 1 + 9 + 9 = 19, not a multiple of 3. No.
- ยทBy 5? Doesn't end in 0 or 5. No.
- ยทBy 7? 199 = 7ร28 + 3. No.
- ยทBy 11? 199 = 11ร18 + 1. No.
- ยทBy 13? 199 = 13ร15 + 4. No.
- ยทBy 17? Stop โ 17ยฒ = 289 > 199, so 17 is past the square root. Done.
Nothing in range divides it. 199 is PRIME โ proved, not guessed. โ
Euclid's masterpiece: the primes never run out
Around 300 BC, Euclid proved there are infinitely many primes, with one of the most famous proofs in history. Suppose โ just to watch it collapse โ that the complete list of primes were finite: pโ, pโ, ..., up to some last one. Now build this number:
N = (pโ ร pโ ร ... ร every prime on the list) + 1
N is bigger than 1, so by step 5 of our theorem, some prime q divides N. That prime q must be on the list (the list was supposed to be ALL primes). But then q divides the big product โ and it also divides N. A number that divides both must divide their difference, which is N โ product = 1. No prime divides 1. Contradiction! The finite list is impossible, so the primes go on forever. โ
Try the construction on tiny lists: from {2, 3, 5} we get 2ร3ร5 + 1 = 31 โ a brand-new prime. From {2, 3, 5, 7, 11, 13} we get 30031, and it turns out that 30031 = 59 ร 509 โ two primes that were NOT on the list. The machine always produces new primes, whether N itself is prime or not. (You'll meet Euclid again in Lesson 5, with an even more practical trick.)
โ๏ธ Your Turn!
Is 173 prime? Is 143? Estimate the square root first, then run the checks.
๐ Show the answers
Answers: 173 โ since 13ยฒ = 169 and 14ยฒ = 196, โ173 is between 13 and 14, so check 2, 3, 5, 7, 11, 13. Odd; 1+7+3 = 11 (no 3); doesn't end in 0/5; 173 = 7ร24 + 5; 173 = 11ร15 + 8; 173 = 13ร13 + 4. Nothing works โ 173 is PRIME. 143 โ check the same list: odd; 1+4+3 = 8 (no 3); not 5; 143 = 7ร20 + 3 (no 7); but 143 = 11 ร 13 exactly โ COMPOSITE, caught by 11.