Skip to content
Topos Uranos

Summary

This lesson defines the greatest common divisor and the least common multiple of two natural numbers, and teaches how to compute them in two ways: by means of the prime factorization and by means of the Euclidean algorithm, which does not require factoring. From the algorithm one derives Bézout’s identity, according to which the greatest common divisor is an integer combination of the two numbers, and from it, the relation between both concepts, the character of coprime numbers, the reduction and the addition of fractions, and the complete solution of linear Diophantine equations, with their applications to problems of coins and of measuring.

Learning objectives

  1. Compute the greatest common divisor and the least common multiple by means of the prime factorization, and justify the relation between them.
  2. Apply the Euclidean algorithm and its extended version to obtain the greatest common divisor and the coefficients of Bézout’s identity.
  3. Recognize coprime numbers and use the greatest common divisor and the least common multiple to reduce and add fractions.
  4. Decide whether a linear Diophantine equation has a solution, describe all its solutions and apply it to problems with natural restrictions.

The greatest common divisor and the least common multiple

In the lesson on divisibility and division with remainder the relation d∣ad \mid a between two natural numbers was studied. When two numbers are considered at once, what matters are the divisors they have in common and the multiples they share. Every pair of natural numbers aa and bb has at least one common divisor, namely 11, and at most finitely many of them, because no divisor of aa exceeds aa; it has, moreover, infinitely many common multiples, among them the product abab. If this is so, the following definition makes sense.

Definition (greatest common divisor and least common multiple). The greatest common divisor of two natural numbers aa and bb, written gcd⁡(a,b)\operatorname{gcd}(a, b), is the greatest natural number that divides both. The least common multiple, written lcm⁡(a,b)\operatorname{lcm}(a, b), is the least natural number that is a multiple of both.

The second is the least element of a nonempty set of natural numbers, which exists by the well-ordering principle. The first is the greatest element of the set of common divisors, which is nonempty and bounded by aa; that a nonempty set of natural numbers bounded above has a greatest element also follows from well-ordering: the set of its upper bounds is nonempty and has a least element MM, and MM belongs to the set, because otherwise every element would be less than MM and, since there are no natural numbers between M−1M - 1 and MM, not greater than M−1M - 1, which would be an upper bound less than MM (if M=1M = 1, the set is {1}\{1\} and contains MM). For example, the common divisors of 1212 and 1818 are 11, 22, 33 and 66, and their common multiples are 3636, 7272, 108108, and so on:

gcd⁡(12,18)=6,lcm⁡(12,18)=36\operatorname{gcd}(12, 18) = 6, \qquad \operatorname{lcm}(12, 18) = 36

Some particular cases follow immediately from the definition: gcd⁡(a,1)=1\operatorname{gcd}(a, 1) = 1 and lcm⁡(a,1)=a\operatorname{lcm}(a, 1) = a; gcd⁡(a,a)=lcm⁡(a,a)=a\operatorname{gcd}(a, a) = \operatorname{lcm}(a, a) = a; and, if aa divides bb, then gcd⁡(a,b)=a\operatorname{gcd}(a, b) = a and lcm⁡(a,b)=b\operatorname{lcm}(a, b) = b. Both operations are, moreover, symmetric: the order of the numbers does not change the result.

Computation by means of the prime factorization

By the fundamental theorem of arithmetic, every natural number greater than 11 factors uniquely into primes. It is convenient to write aa and bb with the same primes p1,…,pkp_1, \ldots, p_k, allowing zero exponents for the primes that appear in only one of them:

a=p1α1p2α2⋯pkαk,b=p1β1p2β2⋯pkβka = p_1^{\alpha_1} p_2^{\alpha_2} \cdots p_k^{\alpha_k}, \qquad b = p_1^{\beta_1} p_2^{\beta_2} \cdots p_k^{\beta_k}

A natural number dd divides aa exactly when no primes other than those of aa appear in its factorization, each with an exponent not greater than the one it has in aa. It follows that dd divides both aa and bb when the exponent of each prime in dd exceeds neither of the two exponents; the greatest common divisor is therefore obtained by taking, for each prime, the smaller of the two exponents. Likewise, mm is a common multiple when the exponent of each prime in mm reaches both, and the least common multiple takes, for each prime, the larger of the two exponents. For example:

360=23⋅32⋅51⋅70,84=22⋅31⋅50⋅71360 = 2^3 \cdot 3^2 \cdot 5^1 \cdot 7^0, \qquad 84 = 2^2 \cdot 3^1 \cdot 5^0 \cdot 7^1
gcd⁡(360,84)=22⋅31⋅50⋅70=12,lcm⁡(360,84)=23⋅32⋅51⋅71=2520\operatorname{gcd}(360, 84) = 2^2 \cdot 3^1 \cdot 5^0 \cdot 7^0 = 12, \qquad \operatorname{lcm}(360, 84) = 2^3 \cdot 3^2 \cdot 5^1 \cdot 7^1 = 2520

The method is clear, but it depends on knowing how to factor, and factoring large numbers is very costly: no fast procedure for doing so is known. The algorithm of the next section computes the greatest common divisor without factoring, with divisions alone.