In short

Number theory studies the properties of integers — especially divisibility and primes. An integer a divides b if b = ak for some integer k. A prime is an integer greater than 1 whose only positive divisors are 1 and itself; every other integer greater than 1 is composite. The Fundamental Theorem of Arithmetic says every integer \geq 2 factors into primes in exactly one way (up to order). The greatest common divisor (GCD) and least common multiple (LCM) of two integers capture how their prime factorisations overlap and combine, and the Euclidean algorithm computes the GCD without ever factoring anything. Two integers whose GCD is 1 are co-prime.

Take the number 60. You can break it into 2 \times 30, then 2 \times 2 \times 15, then 2 \times 2 \times 3 \times 5. Those four factors — 2, 2, 3, 5 — are all prime, and no matter how you split 60 apart, you always end up with the same primes in the same quantities. Try it: start with 60 = 6 \times 10 = (2 \times 3) \times (2 \times 5) = 2 \times 2 \times 3 \times 5. Same answer. Or 60 = 4 \times 15 = (2 \times 2) \times (3 \times 5) = 2 \times 2 \times 3 \times 5. Same answer again.

This is not a coincidence. It is a theorem — the Fundamental Theorem of Arithmetic — and it says that the primes are the atoms of the integers. Every integer greater than 1 is either prime itself or built from primes in a unique way. The entire subject of number theory grows from this one fact: that the integers have a hidden atomic structure, and that structure is rigid.

Number theory is one of the oldest branches of mathematics. Indian mathematicians — Aryabhata, Brahmagupta, Bhaskara II — studied divisibility, primes, and the relationships between integers centuries before the subject had a formal name. The tools are elementary — you need nothing beyond multiplication, division, and careful reasoning — but the results are deep. Many of the hardest unsolved problems in mathematics are number theory problems stated in language a school student can understand.

This article covers the foundations: divisibility, primes and composites, the Fundamental Theorem, the GCD and LCM (including the Euclidean algorithm for computing them), and co-prime numbers.

Divisibility

The most basic relation in number theory is divisibility. An integer a divides an integer b — written a \mid b — if there exists an integer k such that b = ak. The notation a \mid b is read "a divides b" or "b is divisible by a" or "a is a factor of b" or "b is a multiple of a." All four phrases mean the same thing.

Divisibility

Let a and b be integers with a \neq 0. Then a \mid b (read "a divides b") if and only if there exists an integer k such that b = ak.

If no such k exists, write a \nmid b ("a does not divide b").

Some examples: 3 \mid 12 because 12 = 3 \times 4. 7 \mid 49 because 49 = 7 \times 7. 5 \nmid 13 because no integer k satisfies 13 = 5k. And 1 \mid n for every integer n, because n = 1 \times n.

Three properties of divisibility that you will use constantly:

Divisibility as equally spaced jumps on the number lineA number line from 0 to 15. Arcs of length 3 are drawn from 0 to 3, 3 to 6, 6 to 9, 9 to 12, and 12 to 15, showing that 3 divides 12 because four equal jumps of 3 land exactly on 12. The point at 12 is highlighted with a red dot and the point at 13 has an open circle showing 3 does not divide 13. 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3 | 12 3 ∤ 13
Divisibility visualised as equal jumps. Starting from $0$, each jump has length $3$. After four jumps you land exactly on $12$ — so $3 \mid 12$. But no whole number of jumps lands on $13$ — so $3 \nmid 13$.

Primes and composites

An integer p > 1 is prime if its only positive divisors are 1 and p itself. An integer n > 1 that is not prime is composite — it has at least one positive divisor other than 1 and n.

The first few primes: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, \dots

Notice that 2 is the only even prime. Every other even number is divisible by 2 (and by itself and 1), so it has at least three positive divisors and is therefore composite. Also notice that 1 is neither prime nor composite — by convention, primality starts at 2.

How do you check whether a number is prime? For a number n, you only need to test divisors up to \sqrt{n}. The reason: if n = a \times b with a \leq b, then a \leq \sqrt{n} (because if both a and b exceeded \sqrt{n}, their product would exceed n). So if n has no prime divisor \leq \sqrt{n}, it is prime.

For example, is 97 prime? \sqrt{97} \approx 9.85, so you only need to check the primes up to 9: those are 2, 3, 5, 7. Is 97 divisible by 2? No (it is odd). By 3? 9 + 7 = 16, not divisible by 3. By 5? Does not end in 0 or 5. By 7? 97 = 7 \times 13 + 6, so no. Therefore 97 is prime.

Are there infinitely many primes? Yes. The proof, one of the most elegant in all of mathematics, goes like this. Suppose there are only finitely many primes: p_1, p_2, \dots, p_r. Form N = p_1 \cdot p_2 \cdots p_r + 1. This number N is not divisible by any of p_1, \dots, p_r (dividing by any p_i leaves a remainder of 1). But N > 1, so it must have a prime factor — and that prime factor is none of p_1, \dots, p_r. This contradicts the assumption that the list was complete. Therefore the primes are infinite. (This is a proof by contradiction.)

The Fundamental Theorem of Arithmetic

Fundamental Theorem of Arithmetic

Every integer n \geq 2 can be expressed as a product of prime numbers:

n = p_1^{a_1} \cdot p_2^{a_2} \cdots p_r^{a_r}

where p_1 < p_2 < \dots < p_r are primes and a_1, a_2, \dots, a_r are positive integers. This representation is unique — no other set of primes and exponents gives the same n.

The theorem has two parts: existence (every integer \geq 2 can be factored into primes) and uniqueness (the factorisation is the only one). Existence is proved by strong induction: if n is prime, it is its own factorisation; if n is composite, n = ab with 2 \leq a, b < n, and both a and b factor into primes by the inductive hypothesis, so n does too. Uniqueness is harder and relies on a key property of primes: if p \mid ab, then p \mid a or p \mid b (or both). This property — called Euclid's lemma — is what separates primes from other numbers and makes the factorisation rigid.

Some prime factorisations:

n Prime factorisation
12 2^2 \times 3
45 3^2 \times 5
100 2^2 \times 5^2
360 2^3 \times 3^2 \times 5
2310 2 \times 3 \times 5 \times 7 \times 11

The number 2310 is special — it is the product of the first five primes, each appearing exactly once. Such numbers are called primorial products.

Factor tree for 360A tree diagram showing 360 at the top. It splits into 2 and 180. Then 180 splits into 2 and 90. Then 90 splits into 2 and 45. Then 45 splits into 3 and 15. Then 15 splits into 3 and 5. The leaves of the tree are circled in red: 2, 2, 2, 3, 3, 5. The final factorisation 2 cubed times 3 squared times 5 is written at the bottom. 360 2 180 2 90 2 45 3 15 3 5 360 = 2³ × 3² × 5
A factor tree for $360$. At each node, the number is split into two factors. The process continues until every leaf is prime (circled in red). Reading off the leaves: $360 = 2 \times 2 \times 2 \times 3 \times 3 \times 5 = 2^3 \times 3^2 \times 5$. No matter which splits you choose at each step, the final collection of prime leaves is always the same — that is the uniqueness guarantee of the Fundamental Theorem.

GCD and LCM

Given two positive integers a and b, their greatest common divisor \gcd(a, b) is the largest positive integer that divides both a and b. Their least common multiple \operatorname{lcm}(a, b) is the smallest positive integer that is a multiple of both a and b.

Using prime factorisations, both are easy to compute. Write:

a = 2^{a_1} \cdot 3^{a_2} \cdot 5^{a_3} \cdots, \quad b = 2^{b_1} \cdot 3^{b_2} \cdot 5^{b_3} \cdots

(where the exponents are \geq 0). Then:

\gcd(a, b) = 2^{\min(a_1, b_1)} \cdot 3^{\min(a_2, b_2)} \cdot 5^{\min(a_3, b_3)} \cdots
\operatorname{lcm}(a, b) = 2^{\max(a_1, b_1)} \cdot 3^{\max(a_2, b_2)} \cdot 5^{\max(a_3, b_3)} \cdots

The GCD takes the minimum exponent at each prime (the overlap), and the LCM takes the maximum (the union). A beautiful consequence:

\gcd(a, b) \times \operatorname{lcm}(a, b) = a \times b

This identity holds for all positive integers a, b, and it follows from \min(x, y) + \max(x, y) = x + y applied to each prime exponent.

The Euclidean algorithm

Factoring large numbers into primes is hard. The Euclidean algorithm computes \gcd(a, b) without factoring — it uses only repeated division with remainder.

The key insight: \gcd(a, b) = \gcd(b, a \bmod b), where a \bmod b is the remainder when a is divided by b. Since the remainder is always smaller than b, the numbers shrink at every step, and the process terminates when the remainder hits 0. At that point, the last non-zero remainder is the GCD.

Example: \gcd(252, 105).

252 = 2 \times 105 + 42
105 = 2 \times 42 + 21
42 = 2 \times 21 + 0

The last non-zero remainder is 21, so \gcd(252, 105) = 21.

Check by factoring: 252 = 2^2 \times 3^2 \times 7 and 105 = 3 \times 5 \times 7. The common primes are 3^1 and 7^1, so \gcd = 3 \times 7 = 21. The algorithm gives the same answer, but it never needed the factorisations.

The Euclidean algorithm is ancient — it appears in Aryabhata's Aryabhatiya (499 CE) in the context of solving linear equations, and the method of successive remainders was well known to Indian mathematicians long before it received its European name.

Euclidean algorithm for GCD of 252 and 105Three rows showing the steps of the Euclidean algorithm. Row 1: 252 equals 2 times 105 plus 42. Row 2: 105 equals 2 times 42 plus 21. Row 3: 42 equals 2 times 21 plus 0. The last non-zero remainder 21 is highlighted in red as the GCD. Step Division Remainder 1. 252 = 2 × 105 + 42 42 2. 105 = 2 × 42 + 21 21 3. 42 = 2 × 21 + 0 0 (stop) gcd(252, 105) = 21
The Euclidean algorithm in three steps. Each step replaces the larger number with the remainder of dividing the two. The remainders shrink: $42, 21, 0$. The last non-zero remainder — $21$ — is the GCD. The algorithm is fast even for very large numbers, because the remainders shrink by at least half every two steps.

Co-prime numbers

Two integers a and b are co-prime (also called relatively prime) if \gcd(a, b) = 1 — that is, they share no common factor other than 1.

Examples: 8 and 15 are co-prime (\gcd(8, 15) = 1, since 8 = 2^3 and 15 = 3 \times 5 share no prime factors). 12 and 35 are co-prime (12 = 2^2 \times 3, 35 = 5 \times 7). But 12 and 18 are not co-prime (\gcd(12, 18) = 6).

Co-primality does not require either number to be prime. The numbers 8 and 9 are both composite, but they are co-prime because 8 = 2^3 and 9 = 3^2 share no prime factors.

A key property: if a and b are co-prime and a \mid bc, then a \mid c. This is because the prime factors of a cannot come from b (since a and b share none), so they must all come from c. This property is used constantly in modular arithmetic and throughout number theory.

When you write a fraction \frac{p}{q} in lowest terms, you are requiring \gcd(p, q) = 1 — that is, p and q are co-prime. The irrationality proofs in proof by contradiction rely on this: assuming \sqrt{2} = p/q in lowest terms and then showing \gcd(p, q) \geq 2 produces the contradiction.

Two worked examples

Example 1: Find $\gcd(540, 168)$ using the Euclidean algorithm, then find $\operatorname{lcm}(540, 168)$

Step 1. Apply the Euclidean algorithm.

540 = 3 \times 168 + 36

Why: divide 540 by 168. The quotient is 3 (since 3 \times 168 = 504) and the remainder is 540 - 504 = 36.

Step 2. Continue with 168 and 36.

168 = 4 \times 36 + 24

Why: 4 \times 36 = 144, remainder 168 - 144 = 24.

Step 3. Continue with 36 and 24.

36 = 1 \times 24 + 12

Why: 1 \times 24 = 24, remainder 36 - 24 = 12.

Step 4. Continue with 24 and 12.

24 = 2 \times 12 + 0

The remainder is 0, so the algorithm stops. The last non-zero remainder is 12.

Why: the zero remainder means 12 divides 24 exactly, and by the chain of equalities, 12 divides both 540 and 168.

Step 5. Compute the LCM using the identity \gcd(a,b) \times \operatorname{lcm}(a,b) = a \times b.

\operatorname{lcm}(540, 168) = \frac{540 \times 168}{12} = \frac{90720}{12} = 7560

Result. \gcd(540, 168) = 12 and \operatorname{lcm}(540, 168) = 7560.

Euclidean algorithm steps for GCD of 540 and 168Four rows showing the Euclidean algorithm. Row 1: 540 equals 3 times 168 plus 36. Row 2: 168 equals 4 times 36 plus 24. Row 3: 36 equals 1 times 24 plus 12. Row 4: 24 equals 2 times 12 plus 0. The value 12 is circled in red as the GCD. Below, the LCM is computed as 540 times 168 divided by 12 equals 7560. 540 = 3 × 168 + 36 remainder 36 168 = 4 × 36 + 24 remainder 24 36 = 1 × 24 + 12 remainder 12 24 = 2 × 12 + 0 remainder 0 → stop 12 gcd(540, 168) = 12 lcm = 540 × 168 / 12 = 7560
The Euclidean algorithm for $\gcd(540, 168)$ terminates in four steps. The remainders shrink rapidly: $36, 24, 12, 0$. The GCD is $12$, and the LCM follows from the identity $\gcd \times \operatorname{lcm} = a \times b$.

Verification by prime factorisation: 540 = 2^2 \times 3^3 \times 5 and 168 = 2^3 \times 3 \times 7. Taking minimum exponents: 2^{\min(2,3)} \times 3^{\min(3,1)} \times 5^{\min(1,0)} \times 7^{\min(0,1)} = 2^2 \times 3^1 = 12. The answer matches. The algorithm found it without factoring.

Example 2: Find the prime factorisation of $1764$ and determine whether $1764$ and $2025$ are co-prime

Step 1. Factor 1764. Start by testing small primes.

1764 \div 2 = 882. 882 \div 2 = 441. 441 is odd, so no more factors of 2.

Why: always start with the smallest prime (2) and keep dividing until you can't. This peels off all factors of 2 at once.

Step 2. Test 3. The digit sum of 441 is 4 + 4 + 1 = 9, which is divisible by 3.

441 \div 3 = 147. 147 \div 3 = 49. The digit sum of 49 is 13, not divisible by 3.

Why: the digit-sum test is a quick divisibility check for 3 — a number is divisible by 3 if and only if the sum of its digits is divisible by 3.

Step 3. Test 5. 49 does not end in 0 or 5, so 5 \nmid 49. Test 7: 49 = 7 \times 7.

So 1764 = 2^2 \times 3^2 \times 7^2.

Why: 49 = 7^2 is a well-known perfect square. After extracting it, no more primes remain.

Step 4. Factor 2025. 2025 \div 5 = 405. 405 \div 5 = 81. 81 = 3^4.

So 2025 = 3^4 \times 5^2.

Why: same process — test small primes, divide them out.

Step 5. Check if 1764 and 2025 are co-prime.

1764 = 2^2 \times 3^2 \times 7^2 and 2025 = 3^4 \times 5^2.

They share the prime 3: \gcd(1764, 2025) = 3^{\min(2,4)} = 3^2 = 9.

Since \gcd \neq 1, they are not co-prime.

Result. 1764 = 2^2 \times 3^2 \times 7^2, and \gcd(1764, 2025) = 9, so they are not co-prime.

Venn diagram of prime factors of 1764 and 2025Two overlapping circles. The left circle is labelled 1764 and contains 2 squared and 7 squared in its exclusive region. The right circle is labelled 2025 and contains 5 squared in its exclusive region. The overlap contains 3 squared, the shared prime factor. Below, the GCD is shown as 3 squared equals 9. 1764 2025 shared gcd = 3² = 9 → not co-prime
The prime factors of $1764$ and $2025$ drawn as two overlapping sets. The left circle holds $2^2$ and $7^2$ (exclusive to $1764$). The right holds $5^2$ (exclusive to $2025$). The overlap — the prime $3$, appearing with exponent $\min(2, 4) = 2$ — gives the GCD: $3^2 = 9$. Because the overlap is non-empty, the two numbers are not co-prime.

The Venn diagram makes the relationship between GCD and LCM visual: the GCD lives in the overlap, and the LCM is the entire shaded region — all primes from both circles, each taken with its maximum exponent.

Common confusions

Going deeper

If you came here for divisibility rules, prime factorisation, GCD, LCM, and the Euclidean algorithm, you have everything you need. The rest of this section is for readers who want to see the deeper patterns — how primes are distributed among the integers and what questions remain open.

The distribution of primes

The primes thin out as numbers get larger, but they never stop. The Prime Number Theorem gives a precise estimate: the number of primes up to N, written \pi(N), is approximately N / \ln N for large N. So among the first million integers, roughly 1{,}000{,}000 / \ln(1{,}000{,}000) \approx 72{,}382 are prime. The actual count is 78{,}498 — the approximation is imperfect but captures the right order of magnitude. The theorem says primes become rarer at a rate governed by the natural logarithm.

The Goldbach conjecture

One of the most famous unsolved problems in mathematics: every even integer greater than 2 can be written as the sum of two primes. For example, 4 = 2 + 2, 6 = 3 + 3, 8 = 3 + 5, 10 = 5 + 5, 12 = 5 + 7. The conjecture has been verified computationally up to 4 \times 10^{18} (four billion billion), and no one has found a counterexample. But no one has proved it either. It has been open since 1742 — nearly three centuries.

Bezout's identity

The Euclidean algorithm does more than compute the GCD — it can express the GCD as a linear combination of a and b. That is, for any positive integers a, b, there exist integers x, y (possibly negative) such that:

\gcd(a, b) = ax + by

This is Bezout's identity, and the integers x, y can be found by running the Euclidean algorithm backwards (the "extended" Euclidean algorithm). Aryabhata described this technique — which he called kuttaka ("the pulveriser") — for solving indeterminate linear equations, and it remains one of the most useful algorithms in all of number theory.

For example, \gcd(252, 105) = 21, and indeed 21 = 252 \times 1 + 105 \times (-2): check 252 - 210 = 42... let's be more careful. From the algorithm: 42 = 252 - 2 \times 105 and 21 = 105 - 2 \times 42 = 105 - 2(252 - 2 \times 105) = 5 \times 105 - 2 \times 252. So 21 = (-2) \times 252 + 5 \times 105. The GCD is a linear combination of the two original numbers.

Where this leads next

Number theory is the foundation for several important topics ahead.