Academy
MathsNumber TheoryGcd LcmBezout's Identity

Bezout's Identity

The GCD is not just a maximum — it is the smallest linear combination of two integers. Bezout's Identity reframes everything, and Euclid's Lemma follows from it.

The Euclidean Algorithm computes gcd(a,b)\gcd(a, b). But what is gcd(a,b)\gcd(a, b)?

"The largest number dividing both" is a correct definition. It's not an illuminating one. Here is the illuminating one:

gcd(a,b)\gcd(a, b) is the smallest positive integer of the form ax+byax + by, where xx and yy are integers.

This is Bezout's Identity. It reframes the GCD from a property of division into a property of reachability — which integers can you construct from aa and bb using addition and subtraction?


The theorem

Bezout's Identity. For any integers a,ba, b not both zero, there exist integers x,yx, y such that:

ax+by=gcd(a,b)ax + by = \gcd(a, b)

And the set {ax+by:x,yZ}\{ax + by : x, y \in \mathbb{Z}\} is exactly the set of all multiples of gcd(a,b)\gcd(a, b).


Finding the coefficients — back-substitution

Run the Euclidean Algorithm. Then read the steps backwards.

Example. Find integers x,yx, y such that 1071x+462y=211071x + 462y = 21.

First, run the Euclidean Algorithm:

1071 = 2 \times 462 + 147 \tag{1} 462 = 3 \times 147 + 21 \tag{2} 147 = 7 \times 21 + 0 \tag{3}

So gcd(1071,462)=21\gcd(1071, 462) = 21.

Now back-substitute. From (2): 21=4623×14721 = 462 - 3 \times 147.

From (1): 147=10712×462147 = 1071 - 2 \times 462.

Substitute:

21=4623(10712×462)=7×4623×107121 = 462 - 3(1071 - 2 \times 462) = 7 \times 462 - 3 \times 1071

So x=3x = -3, y=7y = 7. Check: 1071(3)+462(7)=3213+3234=211071(-3) + 462(7) = -3213 + 3234 = 21. ✓


The key consequence

Corollary. If dad \mid a and dbd \mid b, then dgcd(a,b)d \mid \gcd(a, b).

Proof. Since gcd(a,b)=ax+by\gcd(a,b) = ax + by for some integers x,yx, y, and dd divides both aa and bb, we get dax+by=gcd(a,b)d \mid ax + by = \gcd(a,b). \blacksquare

This is what earns the word greatest. Every common divisor of aa and bb divides gcd(a,b)\gcd(a,b) — so gcd(a,b)\gcd(a,b) is genuinely the largest.

Without Bezout, "greatest" is just a claim. With Bezout, it's a theorem.


What the set {ax+by}\{ax + by\} looks like

Let d=gcd(a,b)d = \gcd(a, b). The set of all integers expressible as ax+byax + by is:

{,2d,d,0,d,2d,3d,}=dZ\{\ldots, -2d, -d, 0, d, 2d, 3d, \ldots\} = d\mathbb{Z}

Exactly the multiples of dd, nothing more, nothing less.

Why nothing less than dd? Any ax+byax+by is divisible by dd (since dad \mid a and dbd \mid b), so no element of the set is smaller than dd in absolute value.

Why dd is reachable? Bezout says so directly.

Why all multiples of dd are reachable? If ax0+by0=dax_0 + by_0 = d, then a(nx0)+b(ny0)=nda(nx_0) + b(ny_0) = nd for any integer nn.


Euclid's Lemma — the payoff

This is the most important application of Bezout at JEE Advanced level.

Euclid's Lemma. If gcd(a,b)=1\gcd(a, b) = 1 and abca \mid bc, then aca \mid c.

Proof. From Bezout: ax+by=1ax + by = 1 for some integers x,yx, y. Multiply both sides by cc:

acx+bcy=cacx + bcy = c

aaca \mid ac and abca \mid bc (given), so aacx+bcy=ca \mid acx + bcy = c. \blacksquare

The prime case. If pp is prime and pabp \mid ab, then pap \mid a or pbp \mid b.

Proof. If pap \nmid a, then gcd(p,a)=1\gcd(p, a) = 1 (since pp is prime, its only divisors are 1 and pp). Euclid's lemma then forces pbp \mid b. \blacksquare

This is the fact that makes prime factorization unique. Uniqueness of the Fundamental Theorem of Arithmetic rests entirely on this lemma.


Worked problems

Problem 1. Prove: if gcd(a,b)=1\gcd(a,b)=1 and ana \mid n and bnb \mid n, then abnab \mid n.

Write n=akn = ak for some integer kk. Then bakb \mid ak and gcd(a,b)=1\gcd(a,b)=1, so by Euclid's lemma, bkb \mid k. Write k=bmk = bm. Then n=abmn = abm, so abnab \mid n. \blacksquare

Problem 2. Prove: gcd(a2,b2)=gcd(a,b)2\gcd(a^2, b^2) = \gcd(a,b)^2.

Let d=gcd(a,b)d = \gcd(a,b), a=dpa = dp, b=dqb = dq, gcd(p,q)=1\gcd(p,q) = 1.

Then a2=d2p2a^2 = d^2 p^2, b2=d2q2b^2 = d^2 q^2. We need gcd(p2,q2)=1\gcd(p^2, q^2) = 1.

Suppose prime rp2r \mid p^2. Then rpr \mid p. If also rq2r \mid q^2, then rqr \mid q. But then rgcd(p,q)=1r \mid \gcd(p,q) = 1, contradiction. So gcd(p2,q2)=1\gcd(p^2, q^2) = 1, giving gcd(a2,b2)=d2\gcd(a^2, b^2) = d^2. \blacksquare

Problem 3. Find all integers nn such that n+1n2+1n+1 \mid n^2 + 1.

Write n2+1=(n+1)(n1)+2n^2 + 1 = (n+1)(n-1) + 2. So if n+1n2+1n+1 \mid n^2+1 then n+12n+1 \mid 2.

Thus n+1{2,1,1,2}n+1 \in \{-2, -1, 1, 2\}, giving n{3,2,0,1}n \in \{-3, -2, 0, 1\}.

Problem 4. Prove that gcd(a,b)gcd(a,c)gcd(a,bc)\gcd(a,b) \cdot \gcd(a,c) \geq \gcd(a, bc) when gcd(b,c)=1\gcd(b,c)=1.

Actually the stronger result holds: gcd(a,bc)=gcd(a,b)gcd(a,c)\gcd(a, bc) = \gcd(a,b) \cdot \gcd(a,c) when gcd(b,c)=1\gcd(b,c)=1.

Let d1=gcd(a,b)d_1 = \gcd(a,b), d2=gcd(a,c)d_2 = \gcd(a,c). Write a=d1s=d2ta = d_1 s = d_2 t. Show d1d2ad_1 d_2 \mid a and d1d2bcd_1 d_2 \mid bc, and that gcd(a/d1,c)=gcd(s,c)\gcd(a/d_1, c) = \gcd(s, c)... the full proof uses Euclid's lemma iteratively.


Edge cases worth naming

  • gcd(0,0)\gcd(0, 0) is undefined (or sometimes set to 0 by convention). Bezout fails here.
  • The Bezout coefficients x,yx, y are not unique. If (x0,y0)(x_0, y_0) works, so does (x0+b/d,y0a/d)(x_0 + b/d, y_0 - a/d) for any integer multiple. The general solution is exactly the theory of Linear Diophantine Equations.
  • Bezout gives existence of coefficients. Finding them requires the Extended Euclidean Algorithm (back-substitution above). Don't confuse the theorem with the algorithm.

The next natural question: since ax+byax + by spans all multiples of gcd(a,b)\gcd(a,b), what happens when you fix the right-hand side and ask for all solutions? That's the complete theory of ax+by=cax + by = c — which lives in Linear Diophantine Equations.