Divisibility and Primes
Every whole number bigger than 1 is built out of primes the way every molecule is built out of atoms. Primes are the indivisible pieces — the numbers that cannot be broken down any further — and understanding them is the entry point to all of number theory. Before we can talk about primes, though, we need a precise language for what "divides" actually means. This page builds that language from the ground up: the divisibility rules that let you factor numbers in your head, the exact definition of a prime, Euclid's stunning 2,300-year-old proof that the primes never run out, and the Sieve of Eratosthenes, an algorithm so clean it is still used today.
Learning Objectives
- State precisely what it means for one integer to divide another.
- Apply and explain why the divisibility rules for 2, 3, 4, 5, 6, 8, 9, 10, and 11 work.
- Distinguish prime, composite, and the special cases 0 and 1.
- Reconstruct Euclid's proof that there are infinitely many primes.
- Use the Sieve of Eratosthenes to list every prime up to a given bound and know why you only sieve up to the square root.
Quick Answer
An integer divides an integer (written ) when for some integer — that is, the division leaves no remainder. A prime is a whole number greater than 1 whose only positive divisors are 1 and itself; a composite has at least one other divisor. The number 1 is neither. Divisibility rules are shortcuts, grounded in place value, for testing divisibility without long division. Euclid proved around 300 BCE that primes are infinite: assuming a complete finite list leads to a contradiction. The Sieve of Eratosthenes lists all primes up to by repeatedly crossing out multiples, and you only need to sieve with primes up to .
Where It Came From
The study of divisibility is as old as counting itself, because the practical problem came first: how do you share things fairly? If 12 loaves must be split among some number of people with none left over, you need to know the divisors of 12. Egyptian and Babylonian scribes worked with these ideas for trade, taxation, and calendar-making thousands of years ago.
The Greeks turned this practical knowledge into a theory. Around 300 BCE, Euclid collected the mathematics of his era into the Elements, and Books VII–IX are devoted entirely to number theory. Euclid needed a rigorous foundation because the Greeks had discovered something disturbing: not all quantities are ratios of whole numbers (irrationality). This pushed them to be extremely careful about what whole numbers are and how they factor. Out of that care came the definition of a prime and Euclid's famous proof of their infinitude — one of the first proofs in history to establish that something goes on forever using pure logic rather than examples.
A generation or so later, Eratosthenes of Cyrene (c. 276–194 BCE), the polymath librarian at Alexandria who also measured the circumference of the Earth, gave a mechanical procedure for finding primes. His "sieve" answered the complementary question: Euclid told us primes never end, but how do we actually list the ones we have? The need was real — mathematicians wanted tables of primes, and hand-computing each one by trial division is exhausting. The sieve trades multiplication for simple counting, and it remains the fastest simple method for generating all small primes.
Divisibility: The Exact Definition
We say divides , written , if there is an integer such that . Equivalently, divided by leaves remainder 0. We call a divisor (or factor) of , and a multiple of .
A few consequences follow immediately:
- Every integer divides 0, because . But 0 divides only 0.
- 1 divides everything, since .
- If and , then and . This "linearity" is the engine behind Euclid's algorithm and most divisibility proofs.
Worked example. Does ? We look for an integer with . Since , yes: , so . Does ? Now , remainder 1, so no.
Divisibility Rules and Why They Work
The rules are not magic — they all come from place value. A number like means . Because have known remainders when divided by small numbers, we can test the whole number by testing its digits.
| Divisor | Rule | Why |
|---|---|---|
| 2 | Last digit is even | 10 is divisible by 2, so only the units digit matters |
| 3 | Digit sum divisible by 3 | , so each power of 10 leaves remainder 1 |
| 4 | Last two digits divisible by 4 | 100 is divisible by 4 |
| 5 | Ends in 0 or 5 | 10 is divisible by 5 |
| 6 | Divisible by 2 and 3 | 6 = 2 × 3 with 2, 3 coprime |
| 8 | Last three digits divisible by 8 | 1000 is divisible by 8 |
| 9 | Digit sum divisible by 9 | too |
| 10 | Ends in 0 | 10 divides 10 |
| 11 | Alternating digit sum divisible by 11 |
Why the rule for 3 (and 9) works. Since , dividing any power of 10 by 3 or 9 leaves remainder 1. So . Every "9…9" part is divisible by 3, leaving exactly the digit sum . Because 16 is not divisible by 3, neither is 3,472. (And , whose digits sum to 15, is divisible by 3.)
Worked example — the rule for 11. Test . Alternate signs from the right: . Since , we conclude . Check: exactly. The rule works because , so consecutive place values alternate between and .
Primes and Composites
A prime number is an integer greater than 1 whose only positive divisors are 1 and itself. A composite number is an integer greater than 1 that has at least one divisor other than 1 and itself. The first several primes are .
Two edge cases trip everyone up:
- 1 is not prime. It has only one divisor (itself), not two. More importantly, if 1 were prime, factorizations would not be unique — you could write . Excluding 1 keeps the Fundamental Theorem of Arithmetic clean: every integer above 1 factors into primes in exactly one way.
- 2 is the only even prime. Every other even number has 2 as a divisor, so it is composite.
Worked example — is 221 prime? We trial-divide by primes up to : 2 (no, odd), 3 (digit sum 5, no), 5 (no), 7 (, no), 11 (alternating sum , no), 13 ( — yes!). So is composite. Notice we never had to test past 14: if had a factor larger than its square root, the paired factor would be smaller than the square root and we would have already found it.
Euclid's Proof That Primes Never End
Here is the argument that has amazed students for two millennia. Euclid shows that no finite list can contain all the primes.
Suppose, for contradiction, that there are only finitely many primes, and list them all:
Now form the number
is bigger than every prime on our list, so by assumption it must be composite, meaning some prime from the list divides it. But also divides the product . If a prime divides both and the product, it must divide their difference — and that difference is exactly . No prime divides 1. Contradiction.
Therefore our assumption was false: there are infinitely many primes.
Worked illustration. Suppose someone claimed the only primes were . Then . Is itself prime? Not necessarily — and that is a subtle point. Here . Neither 59 nor 509 is on the list, so we have found new primes either way. The proof does not claim is prime; it claims forces the existence of a prime outside the list.
The Sieve of Eratosthenes
To list every prime up to , Eratosthenes' method is beautifully mechanical:
- Write the numbers .
- Start with the first uncrossed number (2). It is prime. Cross out every multiple of it beyond itself.
- Move to the next uncrossed number; it is the next prime. Cross out its multiples.
- Repeat. You can stop once your current prime exceeds — everything still uncrossed is prime.
Worked example — primes up to 30. , so we only sieve with 2, 3, and 5.
- Cross multiples of 2: 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30.
- Next uncrossed is 3. Cross 6, 9, 12, 15, 18, 21, 24, 27, 30 (some already gone).
- Next uncrossed is 5. Cross 10, 15, 20, 25, 30.
- Next uncrossed is 7, but , so we stop.
Survivors: — the ten primes below 30.
Why stop at ? Any composite has a prime factor no larger than (its smallest prime factor). So every composite is crossed out by some prime up to ; nothing composite can slip through. A small optimization: when sieving prime , start crossing at , since smaller multiples were already crossed by smaller primes.
Real-World Applications
- Cryptography. RSA encryption, which secures much of internet banking and messaging, relies on the fact that multiplying two large primes is easy but factoring the product back is astronomically hard. The whole system rests on the primes Euclid guaranteed exist.
- Hashing and data structures. Hash tables often use a prime number of buckets because primes spread keys evenly and reduce clustering from patterned inputs.
- Error-correcting codes and check digits. ISBNs and bank routing numbers use divisibility (the mod-11 and mod-10 rules) to catch typos automatically.
- Gears and cycles. Engineers choose gear-tooth counts that are coprime so that the same teeth do not repeatedly mesh, spreading wear evenly.
Common Mistakes
- Thinking 1 is prime. Why wrong: a prime must have exactly two distinct positive divisors; 1 has only one. Correction: 1 is a unit — neither prime nor composite — and excluding it is what makes prime factorization unique.
- Believing Euclid's is always prime. Why wrong: is composite. Correction: the proof only guarantees a new prime exists (as a factor of ), not that itself is prime.
- Sieving or trial-dividing all the way up to . Why wrong: it wastes enormous effort. Correction: stop at — a composite number always has a factor at or below its square root, so nothing is missed.
Comparison and Connections
| Concept | Meaning | Key point |
|---|---|---|
| Factor / divisor | Divides evenly, remainder 0 | Comes in pairs around |
| Multiple | Result of multiplying by an integer | The "reverse" of a factor |
| Prime | Exactly two divisors | Building blocks |
| Composite | More than two divisors | Products of primes |
| Coprime | Share no common factor but 1 | GCD equals 1 |
Divisibility rules connect to modular arithmetic (each rule is a statement about remainders mod that divisor). Primes lead directly to the Fundamental Theorem of Arithmetic and to the greatest common divisor, computed by the Euclidean algorithm. The sieve is your first taste of an algorithm with a provable running time.
Practice Questions
Recall
List all primes between 40 and 60. Answer: 41, 43, 47, 53, 59.
Understanding
Explain in one sentence why the divisibility rule for 9 uses the digit sum. Guidance: Because , every power of 10 leaves remainder 1, so a number and its digit sum have the same remainder mod 9.
Application
Use the rule for 11 to test whether 3,829,684 is divisible by 11. Answer: Alternating sum from the right: . Not divisible by 11.
Analysis
A composite number is claimed to have no prime factor at or below . Show this is impossible. Guidance: Write with . If both exceeded then , a contradiction, so the smaller factor , and its prime divisor is smaller still.
FAQ
Is 2 really prime? It feels too small. Yes. It has exactly two divisors, 1 and 2, which is the definition. It is simply the unique even prime.
Why isn't 1 prime — who decided that? It is a definition chosen so that factorization into primes is unique. If 1 counted, you could pad any factorization with extra 1s.
Does Euclid's proof actually build the "next" prime? No. It proves a prime outside any finite list must exist, but the number it constructs is often composite; the new prime hides among 's factors.
How far do I have to check to confirm a number is prime? Only up to its square root. If nothing at or below divides it, is prime.
Is there a largest known prime? There are infinitely many primes, so there is no largest one at all. But the largest one humans have written down keeps growing — currently these are enormous Mersenne primes found by distributed computing.
Quick Revision
- means for some integer (remainder 0).
- Prime: exactly two divisors. Composite: more than two. 1 is neither; 2 is the only even prime.
- Divisibility rules come from place value: 3 and 9 use digit sums; 11 uses the alternating sum.
- To test primality or sieve, only go up to .
- Euclid: assume finitely many primes, form ; a prime dividing can't be on the list — contradiction.
- Sieve of Eratosthenes: cross out multiples starting at ; survivors are prime.
Related Topics
Prerequisites
Related Topics
- Modular arithmetic and remainders
- Greatest common divisor and the Euclidean algorithm
Next Topics
- The Fundamental Theorem of Arithmetic and prime factorization