๐Ÿ  Home โ€บ ๐Ÿ” Number Theory โ€บ Lesson 2

๐Ÿงฉ Prime Hunting โ€” The Square-Root Proof

๐Ÿ“– Lesson 2 of 8

๐Ÿ“Œ 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:

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?

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.

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.

V.3.1