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:
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
