IMO (Maths Olympiad) /Number Theory

Euclidean Algorithm and Bezout's Identity

Divisibility and Primes · free study notes

Euclidean Algorithm & Bézout’s Identity – Study Notes

(For IIT‑JEE / Competitive Mathematics)


1. Introduction

The Euclidean Algorithm is the most efficient method to compute the greatest common divisor (gcd) of two integers.
The Extended Euclidean Algorithm augments it to produce integers (x,,y) such that

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

This is Bézout’s identity. These tools are indispensable for solving linear Diophantine equations, computing modular inverses, and many other problems in number theory.


2. Euclidean Algorithm

2.1 Definition

For non‑negative integers (a,b) with (a\ge b), define

[ \gcd(a,b)=\gcd!\bigl(b,; a\bmod b\bigr) ]

Iterating this reduction yields the gcd.

2.2 Algorithm (Iterative)

Input:   a ≥ b ≥ 0
while b ≠ 0
    r ← a mod b
    a ← b
    b ← r
return a          // a now equals gcd(a0,b0)

2.3 Proof of Correctness

Lemma (Division Algorithm).
For integers (a,b>0), there exist unique integers (q,r) such that
(a = qb + r) with (0 \le r < b).

Using the lemma, let (a = q_1 b + r_1) with (0 \le r_1 < b).
Any common divisor (d) of (a) and (b) also divides (r_1 = a - q_1 b).
Thus (\gcd(a,b)=\gcd(b,r_1)).
Applying the same argument to ((b,r_1)) gives the recursive step.

Since each remainder is strictly smaller than the previous divisor, the process must terminate after at most (\log_2(\min(a,b))) steps.

2.4 Complexity

The number of iterations is (O(\log \min(a,b))).
Each step involves a single division and modulo, so the total time is (O(\log \min(a,b))) in the classical (unbounded‑precision) setting.


3. Extended Euclidean Algorithm

3.1 Goal

Find integers (x,y) such that

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

3.2 Algorithm (Iterative)

Input:   a, b  (a,b ≠ 0)
x0, y0  ← 1, 0          // coefficients for a
x1, y1  ← 0, 1          // coefficients for b
while b ≠ 0
    q ← a

Your note

Page 1

Doubt hai is topic me?

Free AI teacher se poocho — 24/7, step by step.