Prime numbers
A prime number has exactly two divisors: one and itself. Learn the definition, the sieve of Eratosthenes, prime factorisation, and the fundamental theorem of arithmetic.
Before you start
This topic builds on earlier ideas. Before you start, it's worth working through the lessons below — they'll make everything click:
- GCD and LCMThe greatest common divisor and the lowest common multiple of two numbers. Learn the divisibility rules, the listing method, the Euclidean algorithm, and the formula tying GCD to LCM.
- RootsA root is the inverse of raising to a power. Learn square and cube roots, arithmetic with roots, taking a factor out of a radical and absorbing one under it, estimating and comparing roots, and rationalising a denominator.
Where this is used
Real situations where you count exactly the way this lesson teaches:
- Online bankingThe padlock beside your bank's address rests on multiplying being easy and factoring not: you read 91 = 7 · 13 at a glance, but no machine today can split a 617-digit RSA key back into the two 300-plus-digit primes it was built from.
- Gear designAn engineer pairs a 17-tooth gear with a 24-tooth one because the counts are coprime: the same two teeth meet again only after lcm(17, 24) = 408 engagements, so the wear spreads evenly.
- ProgrammingA hash table of size 100 drops every key divisible by 10 into just 10 buckets. Size it 97 — a prime — and the same keys spread across all 97.
All formulas
Definition of a prime
its only divisors are 1 and itself
Fundamental theorem of arithmetic
the prime factorisation is unique
Primality test
divisors up to the square root are enough
GCD and LCM from factorisations
lowest exponents for the GCD, highest for the LCM
A prime number is a natural number greater than with exactly two divisors: one and itself. A number greater than with more divisors is composite.
The list starts like this:
Two edge cases are worth remembering separately. One is not prime — it has a single divisor. Two is prime, and it is the only even prime: every other even number is divisible by and therefore has at least three divisors.
There are infinitely many primes — Euclid noticed that if the list were finite, the number equal to the product of all its entries plus would be divisible by none of them.
The sieve of Eratosthenes
The oldest way to list primes: write the numbers from to , then cross out the multiples of each number that survives. Only the primes remain.
For : keep and cross out ; keep and cross out ; keep and cross out . Untouched are:
The primality test — up to the square root
Testing a single number needs no sieve. It is enough to look for divisors up to the square root:
Why? Because if and both factors were larger than , their product would exceed . The smaller factor therefore always sits below the square root.
Prime factorisation
Every natural number greater than can be written as a product of primes — and in only one way (up to the order of the factors). That is the fundamental theorem of arithmetic:
Primes are the "atoms" of arithmetic: every number is built from them, and in exactly one way.
The factorisation comes from dividing by successive primes, smallest first:
GCD and LCM from factorisations
Factorisation gives a third way — next to listing divisors and the Euclidean algorithm — to compute the GCD and the LCM. Take the exponents of the shared primes: the lowest ones for the GCD, the highest ones for the LCM.
Practice
Work through a set of exercises — they get harder as you go. At the end you'll see your score and the mistakes worth reviewing.
Common mistakes
- Counting as prime — it has one divisor, and the definition asks for exactly two.
- Ruling out for being even — being even is no obstacle; is prime, just the only even one.
- Testing divisors all the way up to — up to is enough, which cuts the work many times over.
- Leaving a composite number in the factorisation — is not a prime factorisation yet; carry on to .
Formula card
Topic: Prime numbers
Definition of a prime
its only divisors are 1 and itself
Fundamental theorem of arithmetic
the prime factorisation is unique
Primality test
divisors up to the square root are enough
GCD and LCM from factorisations
lowest exponents for the GCD, highest for the LCM
