MathLabs

Grade 6

Prime numbers

The indivisible building blocks of every whole number — and the starting point for one of mathematics' longest-running mysteries.

IntuitionBuilding blocks for numbers

Every whole number bigger than 1 is either a prime or is built by multiplying smaller primes together — the way every molecule is built from atoms. Learn the atoms, and you understand how every molecule is put together.

Definition: Prime and composite numbers

A prime number is a whole number greater than 1 whose only positive divisors are 1 and itself. A whole number greater than 1 that is not prime is called composite — it has at least one divisor other than 1 and itself. The number 1 is neither prime nor composite: it has only one positive divisor.

The first primes are 2,3,5,7,11,13,17,19,23,…2, 3, 5, 7, 11, 13, 17, 19, 23, \ldots Notice that 22 is the only even prime — every other even number is divisible by 2, so it has a third divisor besides 1 and itself.

SchoolQuick divisibility tests

Divisibility tests for small numbers
DivisorRuleExample
2Last digit is even (0, 2, 4, 6, 8)128128 ends in 88
3Digit sum is divisible by 3123123: 1+2+3=61+2+3=6
5Last digit is 0 or 5275275 ends in 55
9Digit sum is divisible by 9738738: 7+3+8=187+3+8=18

SchoolThe sieve of Eratosthenes

To find every prime up to some number NN, write down 2,3,4,…,N2, 3, 4, \ldots, N. Cross out every multiple of 22 except 22 itself, then every multiple of 33 except 33 itself, and so on. Whenever you reach a number that hasn't been crossed out, it's prime — cross out its multiples too. What survives the sieve is exactly the list of primes up to NN.

Example: Sieving up to 30

List all primes from 2 to 30 using the sieve.

Solution

Step 1 (Sieving multiples of 2, 3, and 5): Write down all integers from 2 to 30. First cross out multiples of 2 greater than 2 (4, 6, 8, …, 30), then multiples of 3 not yet crossed out (9, 15, 21, 27), and finally multiples of 5 not yet crossed out (25).

Step 2 (Stopping criterion and remaining primes): Primes above 30≈5.5\sqrt{30}\approx5.5 do not need their multiples crossed out, because any composite number ≤30\le30 must have at least one prime factor ≤5\le5. The surviving numbers are the 10 primes up to 30: 2,3,5,7,11,13,17,19,23,292,3,5,7,11,13,17,19,23,29.

SchoolPrime factorization

Every composite number can be broken down into a product of primes. Keep dividing by the smallest prime that fits until only primes remain.

60=2×30=2×2×15=2×2×3×5=22⋅3⋅560 = 2 \times 30 = 2 \times 2 \times 15 = 2 \times 2 \times 3 \times 5 = 2^2 \cdot 3 \cdot 5
n=p1a1p2a2⋯pkak,d(n)=(a1+1)(a2+1)⋯(ak+1)n = p_1^{a_1} p_2^{a_2} \cdots p_k^{a_k}, \qquad d(n) = (a_1 + 1)(a_2 + 1)\cdots(a_k + 1)
Interactive graph network illustrating prime factorization trees and divisor relationships.
Primes (green) and composites (red) on the 1..601..60 grid: every composite number ≤60\le 60 has a prime factor ≤60<8\le \sqrt{60} < 8.

Every whole number greater than 1 can be written as a product of primes in exactly one way, apart from the order of the factors — for example 60=22⋅3⋅560 = 2^2\cdot3\cdot5 and there is no other way to do it.

Why is it true?

This is why primes are called the 'atoms' of arithmetic: there's exactly one recipe for building each number, so knowing the primes and their powers tells you everything about a number's divisors.

Proof

Existence (by minimal counterexample): Suppose there exists an integer n>1n > 1 that cannot be written as a product of primes, and let m>1m > 1 be the smallest such integer. Since every prime is a product of a single prime, mm must be composite, so m=abm = a b for integers satisfying 1<a,b<m1 < a, b < m. By the minimality of mm, both aa and bb are products of primes, whence their product m=abm = a b is also a product of primes—a contradiction.

Euclid's Lemma: Suppose a prime pp satisfies p∣abp \mid a b with p∤ap \nmid a. Because pp is prime and p∤ap \nmid a, we have gcd⁡(p,a)=1\gcd(p, a) = 1. By Bézout's identity, there exist integers x,yx, y such that px+ay=1p x + a y = 1. Multiplying both sides by bb yields p(bx)+(ab)y=bp(b x) + (a b)y = b; since pp divides both p(bx)p(b x) and aba b, pp must divide the right-hand side, giving p∣bp \mid b.

Uniqueness: Assume for contradiction that some integer admits two distinct prime factorizations, and let n=p1p2⋯pr=q1q2⋯qsn = p_1 p_2 \cdots p_r = q_1 q_2 \cdots q_s (ordered so that p1≤⋯≤prp_1 \le \cdots \le p_r and q1≤⋯≤qsq_1 \le \cdots \le q_s) be the smallest such integer. Since p1∣q1q2⋯qsp_1 \mid q_1 q_2 \cdots q_s, repeated application of Euclid's lemma shows that p1p_1 divides some prime qjq_j, which forces p1=qj≥q1p_1 = q_j \ge q_1. By symmetry q1≥p1q_1 \ge p_1, so p1=q1p_1 = q_1. Canceling p1p_1 from both sides produces a smaller integer n/p1<nn / p_1 < n with two distinct prime factorizations, contradicting the minimality of nn.

SchoolAre there infinitely many primes?

There is no largest prime number — the list of primes never ends.

Why is it true?

Euclid's argument (c. 300 BCE): suppose there were only finitely many primes p1,p2,…,pkp_1, p_2, \ldots, p_k. Multiply them all together and add 1: N=p1p2⋯pk+1N = p_1 p_2 \cdots p_k + 1. Dividing NN by any pip_i leaves remainder 1, so none of the pip_i divides NN. But NN must have some prime factor (by the fundamental theorem of arithmetic) — a prime that isn't on the list. So the list was never complete.

Proof

Step 1 (Constructing Euclid's number): Let {p1,p2,…,pk}\{p_1, p_2, \dots, p_k\} be any finite collection of prime numbers. Form the integer N=p1p2⋯pk+1N = p_1 p_2 \cdots p_k + 1 by multiplying all primes in the list and adding 11. Since p1≥2p_1 \ge 2, we have N≥2+1=3>1N \ge 2 + 1 = 3 > 1.

Step 2 (Existence of a prime factor): By the fundamental theorem of arithmetic, every integer N>1N > 1 admits at least one prime divisor qq, so q∣Nq \mid N (where q=Nq = N if NN itself is prime, or q<Nq < N if NN is composite).

**Step 3 (Proving qq is a new prime):** Suppose for contradiction that q=piq = p_i for some index ii. Then q∣p1p2⋯pkq \mid p_1 p_2 \cdots p_k, and since q∣Nq \mid N, the prime qq must divide their linear combination q∣(N−p1p2⋯pk)=1q \mid (N - p_1 p_2 \cdots p_k) = 1. This is impossible because every prime satisfies q≥2q \ge 2. Hence q∉{p1,p2,…,pk}q \notin \{p_1, p_2, \dots, p_k\}, proving that no finite list can contain all prime numbers.

Primes thin out as numbers grow — but Euclid's argument guarantees they never run out. Exactly how rare they become, and how evenly they're spread, is the subject of the prime number theorem and, beyond it, one of the deepest open questions in mathematics today.

UndergraduateReal-World Applications: Public-Key Cryptography (RSA)

Modern internet security (HTTPS, digital signatures, banking) relies on a striking asymmetry in number theory: multiplying two large primes pp and qq to form N=pqN = p q takes milliseconds, whereas factoring N=pqN = p q back into pp and qq when each prime has 300+300+ digits is computationally infeasible. In RSA cryptography (Rivest–Shamir–Adleman, 1977), the modulus N=pqN = p q and encryption exponent ee are published, while the decryption key dd satisfying ed≡1(modφ(N))e d \equiv 1 \pmod{\varphi(N)} requires knowing the secret prime factors to compute Euler's totient φ(N)=(p−1)(q−1)\varphi(N) = (p-1)(q-1). Anyone can encrypt a message MM as C≡Me(modN)C \equiv M^e \pmod{N}, but only the holder of dd can recover M≡Cd(modN)M \equiv C^d \pmod{N}.

Example: Mini-RSA key generation and encryption with primes p = 5, q = 11

Using the primes p=5p = 5 and q=11q = 11 with public exponent e=3e = 3, compute the RSA modulus NN, Euler's totient φ(N)\varphi(N), the private decryption key dd, and the ciphertext CC for the message M=7M = 7.

Solution

Step 1 (Modulus and totient): Multiply the two secret primes to obtain the public modulus N=pq=5×11=55N = p q = 5 \times 11 = 55, and compute Euler's totient φ(55)=(5−1)(11−1)=4×10=40\varphi(55) = (5-1)(11-1) = 4 \times 10 = 40.

Step 2 (Private key and encryption): Solve 3d≡1(mod40)3 d \equiv 1 \pmod{40} for dd; testing multiples of 4040 plus 11 gives d=27d = 27 since 3×27=81=2×40+1≡1(mod40)3 \times 27 = 81 = 2 \times 40 + 1 \equiv 1 \pmod{40}. Encrypting M=7M = 7 with the public key (N,e)=(55,3)(N, e) = (55, 3) yields the ciphertext C≡73=343=6×55+13≡13(mod55)C \equiv 7^3 = 343 = 6 \times 55 + 13 \equiv 13 \pmod{55}.

Which of these numbers is prime?

Why is 2 the only even prime number?

What is the prime factorization of 84?

In Euclid's proof, suppose p1,…,pkp_1,\ldots,p_k were all the primes. Let N=p1p2⋯pk+1N=p_1p_2\cdots p_k+1. What do we know about NN?

References

  1. David M. Burton (2010). Elementary Number Theory
  2. John H. Conway, Richard K. Guy (1996). The Book of Numbers · DOI:10.1007/978-1-4612-4072-3