Prime and composite numbers
If factors are the building blocks of a number, then primes are the atoms: numbers so basic that they cannot be broken any further. Every whole number is either a prime or a product of primes , there are no exceptions.
Concept
A prime number is a whole number greater than that has exactly two factors: and itself. The first few primes are:
A composite number is a whole number greater than that has more than two factors. The first few composites are:
What about ? It has only one factor (itself), so it is neither prime nor composite. It is a special case.
A few quick facts:
- is the only even prime. Every other even number is divisible by , so it has at least three factors (, , and itself).
- All primes after are odd, but not all odd numbers are prime (e.g. is composite).
- There are infinitely many primes. This was proved by Euclid more than years ago , one of the most elegant proofs in mathematics.
- Primes thin out but never stop. There are primes below , and only between and .
The Sieve of Eratosthenes
How do we find all primes below, say, ? The Greek mathematician Eratosthenes invented a beautiful method called the sieve:
- Write all numbers from to .
- Circle . Cross out every other multiple of (i.e. ).
- The next un-crossed number is . Circle it, cross out its multiples.
- The next is . Circle, cross out multiples.
- Continue until you have processed every number up to .
- All remaining (circled) numbers are prime.
You only need to sieve with primes up to , because any composite must have a prime factor .
Why primes matter
Primes are the building blocks of all whole numbers. Just as every word is built from letters, every whole number greater than is built (uniquely) from primes. This is called the Fundamental Theorem of Arithmetic, and it is one of the cornerstones of mathematics.
Primes also have deep modern uses. The encryption that protects bank transactions and online passwords relies on the fact that multiplying two huge primes is easy, but reversing the process (finding the primes from the product) is, with current methods, almost impossibly slow.
Worked examples
Example 1. Is prime?
- Try divisors: . So is a factor.
- Factors of : . More than two.
- is composite.
Example 2. Is prime?
- Check primes up to : that means .
- is odd, not divisible by (digit sum ), does not end in or , no.
- is prime.
Example 3. Find all primes between and .
- Candidates: .
- , composite. even, composite. ? Test : not divisible. . Prime. even. , composite. even. , composite. even. ? Test up to , so : not divisible. Prime.
- Primes: .
Example 4. Twin primes are pairs of primes that differ by , like , , . List twin primes below .
- Below : , , , , , .
Try it yourself
- List all primes less than .
- Is prime? Why or why not?
- Is prime? Show your working.
- Find all composites between and .
- Is the sum of two odd primes always even? Why?
- List the first primes greater than .
- Twin primes: find a pair between and .
- Tricky: are there three primes in a row (each differing by ) other than ? Argue why not.
Activity
Sieve –. On a sheet of paper, draw a grid and write numbers to in it. Cross out (it is not prime). Circle , cross out multiples of . Then circle the next un-crossed () and cross out its multiples. Repeat with , then . Stop. Every uncrossed number is prime. Count them , you should find exactly primes below .