Kayavak / Arithmetic and Numbers / AN·05 Factors, Multiples and Primes / Deeper
Deeper · Arithmetic and Numbers
Factors, Multiples and Primes
The questions the chapter doesn't stop for: why this exists, the model to keep in your head, what changes when an assumption does, how sure we are of each claim, and what's still open. Read it after the chapter; back to the chapter.
Why does this exist?
Divisibility is older than written proofs: Babylonian scribes preferred base 60 partly because 60 has so many factors, and their reciprocal tables list only the "regular" numbers whose reciprocals end (those built from 2, 3 and 5). Euclid's Elements (about 300 BCE) collects the theory in Books VII to IX: the gcd algorithm opens Book VII, the fact that a prime dividing a product divides a factor is Book VII, Proposition 30, and the primes never running out is Book IX, Proposition 20. Eratosthenes' sieve comes from the following century.
The subject then went quiet for a long time. Pierre de Fermat revived it in the 1600s, stating (in a 1640 letter) the "little theorem" that is a multiple of for every prime , the basis of modern primality tests. Carl Friedrich Gauss's Disquisitiones Arithmeticae (1801) introduced the notation of congruences, , and proved unique factorisation carefully. The prime number theorem, that primes near have density about , was conjectured by Gauss and Legendre and proved in 1896, independently, by Jacques Hadamard and Charles de la Vallée Poussin. RSA (1977) made the whole subject practical; cryptographers at GCHQ, the British signals intelligence agency, had found an equivalent scheme in 1973, kept secret until 1997.
The mental model
Try it yourself first: write your own model in the Mental Model Explorer, then compare.
Every whole number above 1 is a product of primes in exactly one way, and nearly every fact about divisibility is a fact about those prime exponents. Remainders behave like the numbers themselves, which turns divisibility questions into small calculations; and the gcd can be found by repeated remainders without factorising at all.
| Question | Answer |
|---|---|
| What is it? | The theory of which whole numbers divide which, and of remainders |
| Problem it solves | Simplifying, scheduling, checking and hiding numbers without doing the full calculation |
| Parts | Divides, factors and multiples, remainders, primes, factorisation, gcd and lcm |
| How it works | Place value gives the divisibility tests; remainders add and multiply; Euclid's algorithm shrinks pairs |
| Assumptions | Whole numbers (negatives work with a remainder convention); divisors other than 0 |
| When they change | In some larger number systems factorisation isn't unique; with fractions every non-zero number divides every other |
| Where it fails | gcd(0, 0) needs a convention; floating point breaks exact tests on large numbers |
| Related ideas | Division with remainder (ch04), lowest terms (ch06), repeating decimals (ch07), number bases (ch02) |
What if?
What if 1 counted as a prime?
Reason it through, then open
Nothing about numbers would change, but every statement about primes would need an exception. "Exactly one factorisation" would fail at once: , so the theorem would have to say "apart from 1s". The sieve would cross out every number as a multiple of 1. Many writers before the 1900s did call 1 a prime; it was dropped because the exceptions piled up, not because of a discovery. The modern definition (exactly two factors) is a choice that makes the theorems clean.
What if there were only finitely many primes?
Reason it through, then open
Multiply them all and add 1. That number leaves remainder 1 on division by every prime on the list, so its prime factors (it has at least one, being above 1) aren't on the list: the list wasn't complete. This is Euclid's argument, and it shows what "finitely many" would break. Every number would be a product of a fixed handful of primes, so the counts of numbers up to built from them would grow only like a power of , far slower than itself: there wouldn't be enough products to go round. Leonhard Euler turned that counting idea into a second proof in 1737, and it led eventually to the prime number theorem.
What if factoring large numbers became easy?
Reason it through, then open
RSA and every system built on it would break: anyone could recover a private key from the public one. That is exactly what Peter Shor's 1994 algorithm would do on a large enough quantum computer, which is why standards bodies are replacing RSA and elliptic-curve key exchange with "post-quantum" methods based on other hard problems. Gcds, primality tests and modular arithmetic would stay easy, as they are now; it's only the gap between multiplying and factoring that cryptography uses, and only that gap would close.
Where the boundary is
| Aspect | Testing whether a number is prime | Finding its prime factors |
|---|---|---|
| Example | Is 1,000,000,007 prime? | What are the factors of a 600-digit product? |
| By trial division | Up to divisions | Up to divisions, the same |
| Best known method | Fast (Miller–Rabin in practice; AKS proved polynomial time in 2002) | No known polynomial-time method on ordinary computers |
| Answer for a 600-digit number | Seconds | Far beyond any computer today |
| Used for | Generating cryptographic keys | Breaking them; so its difficulty is the security |
Derive it
Why a prime dividing a product must divide one of the factors, from Euclid's algorithm.
- Run Euclid's algorithm backwards. For 1071 and 462: , , .
- Rewrite the last useful line as , then replace 147 using the first line: .
- The same steps work for any pair, so the gcd of and can always be written as for some whole numbers and (one of them negative). This is Bézout's identity.
- Now let a prime divide but not . The only factors of are 1 and , so , and step 3 gives .
- Multiply by : . The prime divides and it divides , so it divides the right-hand side, which is .
- Uniqueness of factorisation follows: if two factorisations differed, a prime from one would divide the product of the other, so by step 5 it would divide (and so equal) one of its primes; cancel it and repeat.
How sure are we?
| Claim | How it's known | Where from |
|---|---|---|
| There are infinitely many primes | Theorem | Euclid, Elements IX.20; the chapter's proof |
| Every number above 1 factors into primes in exactly one way | Theorem | Gauss (1801); the derivation above |
| Euclid's algorithm takes at most about five times the digits of the smaller number | Theorem | Lamé (1844); the chapter's lab found at most 23 steps over 100,000 pairs below a million |
| Primes near have density about | Theorem | Prime number theorem, proved 1896; the lab's counts match it |
| Primality can be tested in polynomial time | Theorem | Agrawal, Kayal and Saxena (2002) |
| Factoring large numbers is hard for ordinary computers | Active research | No proof exists; it isn't even known to be truly harder than primality |
| Every even number above 2 is a sum of two primes | Active research | Goldbach's conjecture (1742); checked by computer to |
| 1 is not a prime | Convention | The modern definition; it keeps the theorems free of exceptions |
Still open
Much of the subject is open, and simply stated. The Riemann hypothesis (1859), about exactly how regularly the primes are spread, is the most famous unsolved problem in mathematics. Nobody knows whether there are infinitely many twin primes, whether Goldbach's conjecture holds, or whether there are infinitely many Mersenne primes (), the form of the largest primes known: the record in 2024 had over 41 million digits. And whether factoring is genuinely hard, the assumption beneath public-key cryptography, is not proved.
What would change your mind? The chapter says testing primality is easy and factoring is hard. An algorithm that factored 600-digit numbers quickly on ordinary computers would overturn the second half, and with it much of internet security; a proof that no such algorithm exists would turn a belief into a theorem.
Recall
Why is 1 not counted as a prime?
With it, factorisations wouldn't be unique (any number of 1s could be added); the definition "exactly two factors" excludes it.
What does Euclid's algorithm repeat?
Replace the pair (a, b) by (b, remainder of a divided by b) until the remainder is 0; the last non-zero remainder is the gcd.
What is Bézout's identity?
The gcd of a and b can be written as a·s + b·t for whole numbers s and t, found by running Euclid's algorithm backwards.
When does a prime dividing a product divide one of the factors?
Always, for primes (Euclid's lemma); for composites it can fail, as 6 divides 4 × 9 but neither factor.
What gap does RSA rely on?
Multiplying primes and testing primality are fast, but factoring a large product is not known to be.
Reflect
Be honest with yourself; this stays in your browser. Anything you can't tick yet is what to revisit.