MC35 Number Theory Ch07 Handout-209
MC35 Number Theory Ch07 Handout-209
7.1 Notes
The greatest common divisor of two (non-negative) numbers, denoted gcd(a, b),
is simply what the name implies: the largest positive number that is a divisor of both of
them. You probably already know one way to compute the gcd of two numbers: factor both
of them, and for each prime, take the smallest exponent. For example, gcd(252, 1200) =
22 × 31 = 12: 252 = 22 · 32 · 7 and 1200 = 24 · 3 · 52 , so the smallest exponent of 2 is 22 and
the smallest exponent of 3 is 31 .
We give some simple facts about the gcd:
Theorem 7.1.1. For positive integer a, we have gcd(a, a) = a and gcd(a, 0) = a.
Theorem 7.1.2. For positive integers a, b, c, we have gcd(ac, bc) = c gcd(a, b).
Two numbers are relatively prime if their greatest common divisor is 1. This does
not imply that the numbers are prime. For example, 12 and 35 are relatively prime. n
numbers are pairwise relatively prime if the greatest common divisor between any pair
of them is 1.
Euclidean Algorithm
If the numbers are difficult to factor, there is another way we can compute the gcd of
two numbers. This is called the Euclidean algorithm. The algorithm makes use of the
following lemma:
Lemma 7.1.3. For positive integers a and b such that a ≥ b, we have gcd(a, b) = gcd(a −
b, b).
Proof. We will let d denote the greatest common divisor of a and b. Since d divides a and
b (by definition), d must divide their difference, so d | a − b.
28
MC35N Chapter 7. GCD & LCM
However, we must show that d is actually the greatest common divisor of a − b and b
(we have only shown so far that d is a common divisor of a − b and b). If we assume that
gcd(a − b, b) = d0 for some d0 > d, then d0 divides both a − b and b, implying that d0 divides
their sum, which is (a − b) + b = a. But this implies d0 divides a and b, a contradiction.
Start with the pair (a, b). We can assume a ≥ b. If b > a, then swap a and b.
Repeat until one of a or b is zero. The non-zero number is equal to gcd(a, b).
To speed things up, we can replace (a, b) with (r, b), where r is the remainder when a
is divided by b.
A classic example comes from the very first International Mathematical Olympiad
(IMO):
21n+4
Example 7.1.5 (1959 IMO #1). Prove that the fraction 14n+3 is irreducible for every
natural number n.
Proof. It suffices to show that the numerator and denominator are relatively prime, or that
gcd(21n + 4, 14n + 3) = 1. We can also use the Euclidean algorithm:
29
MC35N Chapter 7. GCD & LCM
Example 7.1.6 (2007 AMC 12B #24). How many pairs of positive integers (a, b) are
there such that gcd(a, b) = 1 and
a 14b
+
b 9a
is an integer?
9a2 + 14b2
Proof. We combine the fractions to get that is an integer, so 9ab | 9a2 + 14b2 .
9ab
We need that 9 | 14b2 for this to be true, so b = 3c for some integer c. Plugging back in,
we find that 27ac | 9a2 + 14 · 9c2 =⇒ 3ac | a2 + 14c2 . Now we need that c | a2 , but
gcd(a, c) = 1, so c must be 1. Then we need that 3a | a2 + 14.
Notice we must have 3 | a2 + 14, which is impossible if a is a multiple of 3. But notice
that if a is not a multiple of 3, then 3 | a2 + 14 (try a few values if you are not convinced!).
Therefore, we need a | a2 +14, so a | 14, which only happens for a = 1, 2, 7 and 14. Plugging
these back in and checking the values of b, all of them work, so there are 4 solutions.
Proof. To prove this, we can equivalently show that lcm(a, b) gcd(a, b) = ab. The main
idea is that if p is any prime, and if νp (a) and νp (b) represent the largest power of p that
divides a and b respectively, then the GCD of a and b will contain pmin(νp (a),νp (b)) in its
prime factorization - that is, νp (gcd(a, b)) = min(νp (a), νp (b)).
Similarly, the LCM of a and b will contain pmax(νp (a),νp (b)) in its prime factorization.
Then gcd(a, b)lcm(a, b) will contain pmin(νp (a),νp (b))+max(νp (a),νp (b)) in its prime factorization.
Using the fact that min(x, y) + max(x, y) = x + y, then the largest power of p that
divides gcd(a, b)lcm(a, b) is pνp (a)+νp (b) . Doing this for all primes p, we can show that the
product of the GCD and LCM of a and b equals ab.
Example 7.1.8 (2018 AMC 10B #23). How many ordered pairs (a, b) of positive integers
satisfy the equation
a · b + 63 = 20 · lcm(a, b) + 12 · gcd(a, b),
where gcd(a, b) denotes the greatest common divisor of a and b, and lcm(a, b) denotes their
least common multiple?
30
MC35N Chapter 7. GCD & LCM
Solution. We can replace a · b with gcd(a, b)lcm(a, b). Letting d = gcd(a, b) and m =
lcm(a, b), we have
It almost looks like we can apply SFFT here, on the expression (d − 20)(m − 12). To
compensate, we add 240 − 63 = 177 to both sides, then use SFFT:
The factor pairs of 177 are 1 × 177 and 3 × 59. Since d ≤ m, the only possibilities
are (d, m) = (21, 189) or (23, 71). The first pair gives 2 solutions (a, b) = (21, 189) and
(189, 21). The second pair gives no solutions. Thus the number of pairs is 2 .
7.2 Examples
1. (Lehigh MC-2008-35) Let an denote the n-digit positive integer all of whose digits
are 1. For example, a3 = 111. What is the greatest common divisor of a45 and a140 ?
2. (Lehigh MC-2014-34) Out of all relatively prime integers a and b, what is the largest
possible value of the greatest common divisor of a + 201b and 201a + b?
3. (Richard Spence) Using the Euclidean algorithm, find a two-digit positive integer n
such that 103n leaves remainder 1 when divided by 46 (hint: compute gcd(46, 103)).
7.3 Exercises
1. (AMC10-2018-A22) Let a, b, c, and d be positive integers such that gcd(a, b) =
24, gcd(b, c) = 36, gcd(c, d) = 54, and 70 < gcd(d, a) < 100. Which of the follow-
ing must be a divisor of a?
31
MC35N Chapter 7. GCD & LCM
3. (HMMT Nov-2015-Guts-15) Find the smallest positive integer b such that 1111b (1111
in base b) is a perfect square. If no such b exists, write “No solution.”
(A) 1500 (B) 1560 (C) 2320 (D) 2480 (E) 2500
32