01 / 20

Divisibility, GCD &
Euclidean Algorithm

Master the foundations of integer divisibility, learn to compute the greatest common divisor, and wield the Euclidean algorithm with confidence.

Discrete Math

What Is Divisibility?

For integers \(a\) and \(b\) with \(a \neq 0\), we say \(a\) divides \(b\) (written \(a \mid b\)) if there exists an integer \(k\) such that:

If no such \(k\) exists, we write \(a \nmid b\). For example: \(3 \mid 12\) because \(12 = 3 \times 4\), but \(5 \nmid 12\) because no integer \(k\) satisfies \(12 = 5k\).

Divisibility on the Number Line

0 3 6 9 12 15 18 +3 +3 +3 +3 +3 +3 Multiples of 3: every dot is divisible by 3 3 | 0, 3 | 3, 3 | 6, 3 | 9, 3 | 12, 3 | 15, 3 | 18

Properties of Divisibility

1
Reflexive: \(a \mid a\) for every nonzero integer \(a\).
2
Transitive: If \(a \mid b\) and \(b \mid c\), then \(a \mid c\).
3
Linear combination: If \(a \mid b\) and \(a \mid c\), then \(a \mid (b \cdot s + c \cdot t)\) for all integers \(s, t\).
4
Multiplication: If \(a \mid b\), then \(a \mid (b \cdot n)\) for every integer \(n\).

The Division Algorithm

For any integers \(a\) and \(d\) with \(d > 0\), there exist unique integers \(q\) (quotient) and \(r\) (remainder) such that:

\(q\) : Quotient
How many complete copies of \(d\) fit into \(a\).
\(r\) : Remainder
What is left over: always satisfies \(0 \leq r < d\).

Example: \(a = 37,\; d = 5\). Then \(37 = 5 \cdot 7 + 2\), so \(q = 7\) and \(r = 2\).

Greatest Common Divisor

The greatest common divisor of integers \(a\) and \(b\), written \(\gcd(a, b)\), is the largest positive integer that divides both \(a\) and \(b\).

Divisors of 12 Divisors of 18 4 12 1 2 3 6 9 18 gcd(12, 18) = 6

GCD vs LCM

\(\gcd(a,b)\) \(\text{lcm}(a,b)\)
Full name Greatest Common Divisor Least Common Multiple
Definition Largest \(d\) dividing both Smallest \(m\) divisible by both
Example: \(12, 18\) 6 36
Relationship \(\gcd(a,b) \cdot \text{lcm}(a,b) = |a \cdot b|\)
Direction Looks down (divisors) Looks up (multiples)

The Euclidean Algorithm

One of the oldest known algorithms (circa 300 BCE). It computes \(\gcd(a, b)\) by repeatedly applying the Division Algorithm.

Repeat until the remainder is \(0\). The last nonzero remainder is the gcd.

1
Divide: Compute \(a = b \cdot q + r\).
2
Replace: Set \(a \leftarrow b\) and \(b \leftarrow r\).
3
Repeat until \(r = 0\). The current \(b\) is \(\gcd\).

Why Does It Work?

1
Shared divisors are preserved. Since \(a = bq + r\), any common divisor of \(a\) and \(b\) also divides \(r\). And any common divisor of \(b\) and \(r\) also divides \(a\).
2
The remainder shrinks. Since \(0 \leq r < b\), the second argument strictly decreases at each step.
3
Termination. A strictly decreasing sequence of non-negative integers must reach \(0\) in finitely many steps.
4
Base case. \(\gcd(d, 0) = d\), so when the remainder hits \(0\), the other value is the answer.

Example: \(\gcd(48, 18)\)

Step 1 \(48 = 18 \times 2 + \) \(12\)
Step 2 \(18 = \) \(12\) \(\times 1 + \) \(6\)
Step 3 \(12\) \(= \) \(6\) \(\times 2 + \) \(0\)
Result Remainder is 0, so \(\gcd(48, 18) = \) \(6\)

Example: \(\gcd(252, 105)\)

Step 1 \(252 = 105 \times 2 + \) \(42\)
Step 2 \(105 = \) \(42\) \(\times 2 + \) \(21\)
Step 3 \(42\) \(= \) \(21\) \(\times 2 + \) \(0\)
Result \(\gcd(252, 105) = \) \(21\)

Example: \(\gcd(1071, 462)\)

Step 1 \(1071 = 462 \times 2 + \) \(147\)
Step 2 \(462 = 147 \times 3 + \) \(21\)
Step 3 \(147 = \) \(21\) \(\times 7 + \) \(0\)
Result \(\gcd(1071, 462) = \) \(21\)

The Extended Euclidean Algorithm

Bezout's Identity guarantees that for any integers \(a, b\), there exist integers \(s, t\) such that:

The extended Euclidean algorithm finds \(s\) and \(t\) by back-substituting through the division steps.

From \(48 = 18 \times 2 + 12 \;\Rightarrow\; 12 = 48 - 18 \times 2\)
From \(18 = 12 \times 1 + 6 \;\Rightarrow\; 6 = 18 - 12 \times 1\)
Sub \(6 = 18 - (48 - 18 \times 2) = \) \((-1)\)\(\cdot 48 +\) \(3\)\(\cdot 18\)

How to Apply the Algorithm

1
Order the inputs. Let \(a \geq b > 0\). If \(a < b\), swap them.
2
Divide. Compute \(a = b \cdot q + r\) using integer division.
3
Check the remainder. If \(r = 0\), then \(\gcd = b\). Stop.
4
Replace and repeat. Set \(a \leftarrow b\), \(b \leftarrow r\), go to step 2.
5
Verify. Confirm both original inputs are divisible by your answer.

Common Mistakes

✕ Wrong Remainder
Computing \(a \bmod b\) incorrectly (e.g., getting a negative remainder or a remainder \(\geq b\)).
✕ Confusing GCD and LCM
Mixing up "largest divisor" with "smallest multiple": gcd goes down, lcm goes up.
✕ Stopping Too Early
Reporting an intermediate remainder instead of continuing until the remainder is exactly \(0\).

Summary: Key Concepts

Concept Definition Notation
Divisibility \(b = a \cdot k\) for some integer \(k\) \(a \mid b\)
Division Algorithm \(a = dq + r\), \(0 \leq r < d\) \(a \bmod d = r\)
GCD Largest positive common divisor \(\gcd(a,b)\)
Euclidean Alg. \(\gcd(a,b) = \gcd(b, a \bmod b)\) Repeat until \(r = 0\)
Bezout's Identity \(\gcd(a,b) = as + bt\) Extended algorithm

Question 1 of 5

Which of the following correctly states that \(7\) divides \(42\)?

Question 2 of 5

Using the Euclidean algorithm, what is \(\gcd(84, 36)\)?

Question 3 of 5

When applying the Division Algorithm to \(a = 97\) and \(d = 11\), what are \(q\) and \(r\)?

Question 4 of 5

If \(\gcd(a, b) = 1\), the integers \(a\) and \(b\) are called:

Question 5 of 5

Bezout's Identity says \(\gcd(a,b) = as + bt\). For \(a = 48, b = 18\), we found \(\gcd = 6\). Which coefficients \((s, t)\) satisfy \(6 = 48s + 18t\)?