UniMaths
Free chapterTry everything here: cards, proofs and practice. Sign up free to save your progress and unlock all 6 chapters.Sign up free
ALG1 · 1

Integers and divisibility

21 concepts · 78 questions

Divisibility, greatest common divisors, Euclid's algorithm, Bézout's identity, Euclid's lemma, unique prime factorisation, lcm, and linear Diophantine equations.

Overview 1The plan of this section

This section answers one question: why does every whole number break into primes in exactly one way? Existence is easy; uniqueness is not obvious (in some number systems it fails). The route is a chain where each result is the tool for the next:

  1. Divisibility (Def. 1.1) and its basic rules (Prop. 1.2).
  2. The division algorithm (Theorem 1.3): every aa is qn+rqn + r with 0≤r<n0\le r < n.
  3. gcd (Def. 1.4), computed by Euclid's algorithm (Theorem 1.6), which is repeated division.
  4. Bézout (Theorem 1.7): running Euclid backwards writes gcd⁡(a,b)=ax+by\gcd(a, b) = ax + by. This is the key step.
  5. Coprime cancellation (Prop. 1.11): if a∣bca\mid bc and gcd⁡(a,b)=1\gcd(a, b) = 1 then a∣ca\mid c.
  6. Euclid's lemma (Theorem 1.14): a prime dividing abab divides aa or bb.
  7. Unique factorisation (Theorem 1.15). Then applications: lcm, equations ax+by=cax + by = c, and irrationality of n\sqrt n.

Goal: every n≥2n\ge2 factors into primes in exactly one way.

Chain: division algorithm → Euclid's algorithm → Bézout (gcd⁡=ax+by\gcd = ax + by) → coprime cancellation → Euclid's lemma → unique factorisation.

Bézout is the hinge: it turns "largest common divisor" into an equation you can calculate with.

Definition 1.1Divisibility

For integers a,ba, b, we say aa divides bb, written a∣ba\mid b, if b=akb = ak for some integer kk. Then aa is a divisor (or factor) of bb and bb is a multiple of aa. If not, write a∤ba\nmid b. Note: a∣ba\mid b is a statement (true or false), while a/ba/b is a number. Everything divides 00 (0=a⋅00 = a\cdot0); 00 divides only 00; ±1\pm1 divide everything. An integer is even if 2∣n2\mid n and odd otherwise.

a∣ba\mid b means b=akb = ak for some integer kk. It is a yes/no statement, not a fraction.

Examples: 3∣123\mid12 (12=3⋅412 = 3\cdot4), −4∣20-4\mid20, 5∤125\nmid12, 7∣07\mid0.

To use it, write it out: "a∣ba\mid b, so b=akb = ak." Every proof in this section starts like that.

Proposition 1.2Basic properties of divisibility

For integers a,b,ca, b, c: (i) if a∣ba\mid b and b∣cb\mid c then a∣ca\mid c; (ii) if a∣ba\mid b and a∣ca\mid c then a∣bx+cya\mid bx + cy for all x,y∈Zx, y\in\mathbb{Z}; (iii) if a∣ba\mid b and b≠0b\ne0 then ∣a∣≤∣b∣|a|\le|b|; (iv) if a∣ba\mid b and b∣ab\mid a then a=±ba = \pm b.

Divisibility is transitive and survives integer linear combinations: a∣b,a∣c⇒a∣bx+cya\mid b, a\mid c\Rightarrow a\mid bx + cy.

Size: a divisor of b≠0b\ne0 is at most ∣b∣|b| in size.

Mutual divisibility: a=±ba = \pm b.

Why it matters: (ii) is used constantly: anything dividing aa and bb divides every ax+byax + by.

Proof

Theorem 1.3The division algorithm

For every integer aa and every integer n≥1n\ge1 there are unique integers qq (the quotient) and rr (the remainder) with

a=qn+r,0≤r<n.a = qn + r,\qquad0\le r < n.

And n∣an\mid a exactly when r=0r = 0. Examples: 47=6⋅7+547 = 6\cdot7 + 5; −17=(−4)⋅5+3-17 = (-4)\cdot5 + 3 (remainders are never negative).

a=qn+ra = qn + r with 0≤r<n0\le r < n, and q,rq, r are unique.

Why it matters: it's the only tool we need to start: Euclid's algorithm is this, repeated, and modular arithmetic is "keep only rr".

Negative aa: −17=(−4)⋅5+3-17 = (-4)\cdot5 + 3, remainder 33, not −2-2.

Proof

Definition 1.4Greatest common divisor

For integers a,ba, b not both 00, the greatest common divisor gcd⁡(a,b)\gcd(a, b) is the largest integer dividing both aa and bb. (It exists since common divisors are bounded by max⁡(∣a∣,∣b∣)\max(|a|, |b|), and it is ≥1\ge1.) Basic facts: gcd⁡(a,b)=gcd⁡(b,a)=gcd⁡(∣a∣,∣b∣)\gcd(a, b) = \gcd(b, a) = \gcd(|a|, |b|); gcd⁡(a,0)=∣a∣\gcd(a, 0) = |a|; gcd⁡(a,1)=1\gcd(a, 1) = 1.

gcd⁡(a,b)\gcd(a, b): the biggest number dividing both. gcd⁡(12,18)=6\gcd(12, 18) = 6.

Signs don't matter: gcd⁡(−12,18)=6\gcd(-12, 18) = 6.

gcd⁡(a,0)=∣a∣\gcd(a, 0) = |a|, since everything divides 00.

The problem: listing divisors is hopeless for big numbers. Euclid's algorithm (coming up: Theorem 1.6) computes the gcd fast.

Lemma 1.5gcd(a, b) = gcd(b, a − qb)

For all integers a,b,qa, b, q: the common divisors of aa and bb are exactly the common divisors of bb and a−qba - qb. Hence gcd⁡(a,b)=gcd⁡(b,a−qb)\gcd(a, b) = \gcd(b, a - qb); in particular gcd⁡(a,b)=gcd⁡(b,r)\gcd(a, b) = \gcd(b, r) when a=qb+ra = qb + r.

Subtracting multiples doesn't change the gcd: gcd⁡(a,b)=gcd⁡(b,a−qb)\gcd(a, b) = \gcd(b, a - qb).

So replace (a,b)(a, b) by (b,r)(b, r) with rr the remainder: the numbers shrink and the gcd stays. This is the engine of Euclid's algorithm.

Proof

Theorem 1.6Euclid's algorithm

Let a≥b>0a\ge b > 0. Define r0=ar_0 = a, r1=br_1 = b, and while rk≠0r_k\ne0 divide: rk−1=qkrk+rk+1r_{k-1} = q_kr_k + r_{k+1} with 0≤rk+1<rk0\le r_{k+1} < r_k. The process stops, and the last non-zero remainder is gcd⁡(a,b)\gcd(a, b). Example: 252=1⋅198+54252 = 1\cdot198 + 54, 198=3⋅54+36198 = 3\cdot54 + 36, 54=1⋅36+1854 = 1\cdot36 + 18, 36=2⋅1836 = 2\cdot18, so gcd⁡(252,198)=18\gcd(252, 198) = 18.

Euclid: divide, keep the remainder, repeat. The last non-zero remainder is the gcd.

Fast: remainders at least halve every two steps, so it takes O(log⁡b)O(\log b) steps.

Example: gcd⁡(252,198)\gcd(252, 198): 54,36,18,054, 36, 18, 0 gives 1818.

Proof

Theorem 1.7Bézout's identity

Motivation. Running Euclid's algorithm backwards expresses the gcd using aa and bb; for 252,198252, 198: 18=54−36=4⋅54−198=4⋅252−5⋅19818 = 54 - 36 = 4\cdot54 - 198 = 4\cdot252 - 5\cdot198. This always works: For integers a,ba, b not both 00, there are integers x,yx, y with ax+by=gcd⁡(a,b)ax + by = \gcd(a, b). In fact gcd⁡(a,b)\gcd(a, b) is the smallest positive integer of the form ax+byax + by. The coefficients are found by running Euclid's algorithm backwards (the extended Euclidean algorithm; see Check 1.20).

gcd⁡(a,b)=ax+by\gcd(a, b) = ax + by for some integers x,yx, y.

Find x,yx, y: run Euclid, then substitute back up the chain. gcd⁡\gcd = the smallest positive combination ax+byax + by.

Why it matters: "largest common divisor" is hard to use in proofs; "=ax+by= ax + by" is an equation you can multiply and rearrange. Every later result in the section uses it.

Proof

Corollary 1.8Every common divisor divides the gcd

If c∣ac\mid a and c∣bc\mid b then c∣gcd⁡(a,b)c\mid\gcd(a, b). So gcd⁡(a,b)\gcd(a, b) is the unique non-negative common divisor that every common divisor divides; and gcd⁡(ma,mb)=mgcd⁡(a,b)\gcd(ma, mb) = m\gcd(a, b) for m≥1m\ge1.

The gcd is "greatest" in the divisibility sense: every common divisor divides it.

Scaling: gcd⁡(ma,mb)=mgcd⁡(a,b)\gcd(ma, mb) = m\gcd(a, b).

This is how gcd is defined in more general rings.

Proof

Definition 1.9Coprime integers

aa and bb are coprime (relatively prime) if gcd⁡(a,b)=1\gcd(a, b) = 1. Examples: 88 and 1515 are coprime (neither is prime, but they share no factor); nn and n+1n + 1 are always coprime.

Coprime: no common factor except 11.

Coprime is not the same as prime: 88 and 1515 are coprime.

Example: gcd⁡(n,n+1)=1\gcd(n, n + 1) = 1: a common divisor divides the difference 11.

Corollary 1.10Coprime iff ax + by = 1

aa and bb are coprime if and only if there are integers x,yx, y with ax+by=1ax + by = 1.

Coprime ⇔ you can write 1=ax+by1 = ax + by.

To prove coprimality, exhibit x,yx, y: e.g. (n+1)⋅1+n⋅(−1)=1(n + 1)\cdot1 + n\cdot(-1) = 1, so gcd⁡(n,n+1)=1\gcd(n, n + 1) = 1.

Why it matters: this equation is what we multiply through in the next result.

Proof

Proposition 1.11If a | bc and gcd(a, b) = 1 then a | c

Let a,b,c∈Za, b, c\in\mathbb{Z} with a∣bca\mid bc and gcd⁡(a,b)=1\gcd(a, b) = 1. Then a∣ca\mid c. Consequence: if a∣na\mid n, b∣nb\mid n and gcd⁡(a,b)=1\gcd(a, b) = 1, then ab∣nab\mid n.

Coprime factors can be cancelled from divisibility: a∣bca\mid bc, gcd⁡(a,b)=1⇒a∣c\gcd(a, b) = 1\Rightarrow a\mid c.

Needs coprimality: 6∣4⋅36\mid4\cdot3 but 6∤36\nmid3.

Corollary: a∣na\mid n, b∣nb\mid n, gcd⁡(a,b)=1⇒ab∣n\gcd(a, b) = 1\Rightarrow ab\mid n.

Why it matters: with a=pa = p prime, this becomes Euclid's lemma.

Proof

Definition 1.12Primes

An integer p≥2p\ge2 is prime if its only positive divisors are 11 and pp. An integer n≥2n\ge2 that is not prime is composite: n=abn = ab with 1<a,b<n1 < a, b < n. (11 is neither.) Equivalently, for p≥2p\ge2: pp is prime iff gcd⁡(p,a)∈{1,p}\gcd(p, a)\in\{1, p\} for every aa, i.e. either p∣ap\mid a or pp and aa are coprime.

Prime: ≥2\ge2 with no divisors except 11 and itself. 2,3,5,7,11,…2, 3, 5, 7, 11, \dots; 11 is not prime.

Key dichotomy: for any aa, either p∣ap\mid a or gcd⁡(p,a)=1\gcd(p, a) = 1. That's what lets Bézout talk about primes.

Proposition 1.13Every n ≥ 2 is a product of primes

Every integer n≥2n\ge2 is a product of one or more primes. In particular every n≥2n\ge2 has a prime divisor, and there are infinitely many primes.

Existence of factorisation is easy: keep splitting composites into smaller factors.

Uniqueness is the hard part (see Theorem 1.15).

Infinitely many primes: p1⋯pk+1p_1\cdots p_k + 1 has a prime factor not on the list.

Proof

Theorem 1.14Euclid's lemma

If pp is prime and p∣abp\mid ab, then p∣ap\mid a or p∣bp\mid b. More generally, if p∣a1a2⋯anp\mid a_1a_2\cdots a_n then p∣aip\mid a_i for some ii. Fails for composite nn: 6∣2⋅36\mid2\cdot3.

Primes can't be split across a product: p∣ab⇒p∣ap\mid ab\Rightarrow p\mid a or p∣bp\mid b. This is what makes prime factorisation unique.

Composite numbers fail it: 6∣2⋅36\mid2\cdot3 but 6∤26\nmid2 and 6∤36\nmid3.

Proof

Theorem 1.15The fundamental theorem of arithmetic

Every integer n≥2n\ge2 can be written as a product of primes n=p1p2⋯prn = p_1p_2\cdots p_r, and this factorisation is unique up to the order of the factors. Grouping equal primes, n=p1e1⋯pkekn = p_1^{e_1}\cdots p_k^{e_k} with p1<⋯<pkp_1 < \cdots < p_k and ei≥1e_i\ge1 uniquely.

Every n≥2n\ge2 factors into primes in exactly one way (up to order).

Existence: keep splitting (Prop. 1.13). Uniqueness: Euclid's lemma lets you match and cancel primes one at a time.

This is where the whole chain pays off.

Use: compare exponents, e.g. a square has all exponents even.

Proof

Definition 1.16Least common multiple

For non-zero integers a,ba, b, the least common multiple lcm⁡(a,b)\operatorname{lcm}(a, b) is the smallest positive integer divisible by both aa and bb. (It exists: ∣ab∣|ab| is a positive common multiple.)

lcm⁡(a,b)\operatorname{lcm}(a, b): smallest positive number both divide. lcm⁡(4,6)=12\operatorname{lcm}(4, 6) = 12.

Exists because ∣ab∣|ab| is a common multiple.

Partner of the gcd: gcd⁡⋅lcm⁡=∣ab∣\gcd\cdot\operatorname{lcm} = |ab| (see Prop. 1.17, next).

Proposition 1.17gcd and lcm from factorisations

If a=∏pieia = \prod p_i^{e_i} and b=∏pifib = \prod p_i^{f_i} (allowing zero exponents), then

gcd⁡(a,b)=∏pimin⁡(ei,fi),lcm⁡(a,b)=∏pimax⁡(ei,fi),gcd⁡(a,b)lcm⁡(a,b)=∣ab∣.\gcd(a, b) = \prod p_i^{\min(e_i, f_i)},\qquad\operatorname{lcm}(a, b) = \prod p_i^{\max(e_i, f_i)},\qquad\gcd(a, b)\operatorname{lcm}(a, b) = |ab|.

Every common multiple is a multiple of the lcm.

gcd: smaller exponents. lcm: larger exponents. gcd⁡(a,b)⋅lcm⁡(a,b)=ab\gcd(a, b)\cdot\operatorname{lcm}(a, b) = ab (for a,b>0a, b > 0).

Example: 12=22⋅312 = 2^2\cdot3, 18=2⋅3218 = 2\cdot3^2: gcd 66, lcm 3636, and 6⋅36=216=12⋅186\cdot36 = 216 = 12\cdot18.

Proof

Theorem 1.18Linear Diophantine equations

Let a,ba, b be non-zero with d=gcd⁡(a,b)d = \gcd(a, b). The equation ax+by=cax + by = c has an integer solution iff d∣cd\mid c. If (x0,y0)(x_0, y_0) is one solution, all solutions are

x=x0+bdt,y=y0−adt,t∈Z.x = x_0 + \frac bdt,\qquad y = y_0 - \frac adt,\qquad t\in\mathbb{Z}.

ax+by=cax + by = c solvable iff gcd⁡(a,b)∣c\gcd(a, b)\mid c.

One solution: scale Bézout. All solutions: add t⋅(b/d,−a/d)t\cdot(b/d, -a/d).

Example: 6x+15y=216x + 15y = 21: (−14,7)+t(5,−2)(-14, 7) + t(5, -2).

Proof

Corollary 1.19√n is irrational unless n is a perfect square

For n∈Nn\in\mathbb{N}, n\sqrt n is rational if and only if nn is a perfect square. More generally, nk\sqrt[k]n is rational iff nn is a perfect kkth power.

n∈Q  ⟺  n\sqrt n\in\mathbb{Q}\iff n is a square. So 2,3,6,12\sqrt2, \sqrt3, \sqrt6, \sqrt{12} are irrational.

Proof: compare prime exponents in a2=nb2a^2 = nb^2; the left side's are all even.

Proof

Check 1.20Check: Euclid and Bézout by hand

Table method. Keep rows (r,x,y)(r, x, y) with r=ax+byr = ax + by, starting (a,1,0)(a, 1, 0) and (b,0,1)(b, 0, 1). Each new row is (row two above) −q⋅- q\cdot(row above), where qq is the quotient of the two rr's. Stop when r=0r = 0; the previous row gives gcd⁡=ax+by\gcd = ax + by. Checks: verify ax+byax + by equals the gcd at the end; the gcd must divide both inputs; the remainders strictly decrease.

Track (r,x,y)(r, x, y) with r=ax+byr = ax + by: new row = older row −q×- q\times newer row.

Always check the answer: compute ax+byax + by.

gcd must divide both numbers, a quick sanity check.