← back to Number Theory

Divisibility

Jim Hefferon · Elementary Number Theory · Ch. 1

An integer a divides b if b = a · k for some integer k. From this single relation flow the division algorithm, the GCD, and the Euclidean algorithm that computes it.

The divides relation

We write a | b ("a divides b") when there exists an integer k such that b = a k. Divisibility is reflexive (a | a) and transitive (if a | b and b | c then a | c), but not symmetric.

Multiples of 3 on the number line 0 1 2 3 4 5 6 7 8 9 10 11 12
Scheme

The division algorithm

For any integers a and b with b > 0, there exist unique integers q (quotient) and r (remainder) such that a = b q + r and 0 ≤ r < b. This is not really an algorithm but an existence theorem. The algorithm is just long division.

Scheme

GCD and the Euclidean algorithm

The greatest common divisor gcd(a, b) is the largest positive integer dividing both a and b. The wpEuclidean algorithm computes it by repeated division: gcd(a, b) = gcd(b, a mod b), bottoming out at gcd(d, 0) = d. It is one of the oldest known algorithms.

Scheme

Bezout's identity

wpBezout's identity: for any integers a and b, there exist integers x and y such that a x + b y = gcd(a, b). The extended Euclidean algorithm finds these coefficients by working backwards through the GCD computation.

Scheme
Neighbors