Introduction
In Number Theory, the most fundamental operations you will run across are that of the Greatest Common Divisor (GCD) and Least Common Multiple (LCM). They appear in every level of contest from computational to olympiad. Although they seem simple, they each have a variety of techniques involved to solve problems involving them as effectively as possible.
Here are their straightforward definitions:
Greatest Common Divisor (GCD): The GCD of a set of positive integers is the largest integer that divides all the integers (this value may also be ). The notation of GCD is where are the numbers to take the GCD of. For instance,
Least Common Multiple (LCM): The LCM of a set of positive integers is the least integer that is divisible by all integers in the set. The notation of LCM is where are the numbers to take the GCD of. For instance,
Handpicked Techniques
When doing a couple examples, you may have noticed that there exists a systematic way of finding both the LCM and GCD of a set of positive integers rather than bashing our head against the wall to find a number that works. This technique being considering the prime factorization. This technique shows up extremely frequently across conetsts, so make sure you know when to use it.
Prime Factorization
For each number in the set of natural numbers , consider the prime factorization:
where is the exponent of prime in .
The GCD takes the minimum exponent of each prime across all numbers:
The LCM takes the maximum exponent of each prime across all numbers:
This gives the useful identity for two numbers:
To takeaway from this, if a problem provides you with an obscure factorial, binomial coefficient, or even information about primes and asks about some form of GCD or LCM, consider the prime factorization.
2017 AMC 8 Problem 12
The smallest positive integer greater than 1 that leaves a remainder of 1 when divided by 4, 5, and 6 lies between which of the following pairs of numbers?
Don't let the remainder of trick you. The problem is only asking for , which is trivially 61.
2020 AMC 12A Problem 21
How many positive integers are there such that is a multiple of , and the least common multiple of and equals times the greatest common divisor of and
As noted above, seeing factorials and should motivate considering the prime factorizations of the given numbers. By Legendre's theorem:
Translating the condition into an equation:
Write , where is coprime to . Any prime dividing would appear on the LCM side (since the LCM keeps every prime in ) but could never appear on the GCD side (since contributes no such prime). So , and the prime factors of lie in .
Since must be a multiple of , we also need .
Matching exponents prime by prime
The LCM takes the max of corresponding exponents; the GCD takes the min. Multiplying the GCD side by bumps the exponent of up by one. Comparing exponents of each prime on both sides:
Prime : .
If , the left side is and the right side is , forcing . If , the left side is and the right side is , which holds for . So — 6 choices.
Prime : .
By the same logic, — 4 choices.
Prime : .
If : left is , right is . ✗ If : left is , right is . ✗ If : left is , right is , forcing . ✓
So is the unique solution — 1 choice. (Note this also satisfies automatically.)
Prime : .
If : both sides are . ✓ If : left is , right is . ✓ If : left is , right is . ✗
So — 2 choices.
Each prime's exponent is chosen independently, so the total number of valid is:
GCD and LCM Toolkit
Beyond the prime factorization definition, there are several manipulation tools that make GCD/LCM problems tractable. Most olympiad-style problems reward recognizing which tool fits the situation rather than grinding through factorizations.
The Euclidean Algorithm
For any positive integers and with ,
Iterating this recursion terminates when the remainder hits , at which point the other operand is the GCD. This may be pretty useful when you need to take large GCDs, and importantly, to simplify gcd expressions. Generally:
Example: .
See Euclidean algorithm for the full treatment, including Bézout's identity!
Bézout's Identity
For any integers , there exist integers such that:
More usefully: an equation has integer solutions if and only if . This connects GCD directly to linear Diophantine equations.
Scaling and Coprimality
Two useful identities for pulling factors in and out:
The second is quite powerful, if you can isolate a coprime factor, you can drop it from the GCD entirely.
Multiplicativity
GCD and LCM are both multiplicative when the arguments split into coprime parts. If :
When to Reach for Which Tool
| Situation | Tool |
|---|---|
| Computing GCD of specific large numbers | Euclidean algorithm |
| GCD involving polynomial expressions in | Subtraction/linear combination |
| Counting solutions to | Bézout's identity |
| Constraints mixing GCD and LCM (like 2020 AMC 12A #21) | Prime factorization + min/max |
| Proving divisibility properties | Bézout or multiplicativity |
| Problems with factorials or highly composite numbers | Prime factorization (Legendre's formula) |
Remarks
As you continue your math journey, you will see increasingly obscure manipulations and identities involving GCD and LCM that we will dive deeper on in more advanced modules like how:
The common thread across all of these: GCD and LCM are fundamentally about prime-by-prime behavior, and the cleverness in any problem usually comes from finding the right way to isolate one prime at a time. Please continue to build the habit of asking "what does each prime contribute?" and most GCD/LCM problems become a lot easier.
Practice Problems
| Status | Source | Problem Name | Difficulty | Tags | ||
|---|---|---|---|---|---|---|
| Mastering AMC 8 | Medium | Show TagsFactors | ||||
| Mastering AMC 8 | Medium | Show TagsFactors | ||||
Module Progress:
Join the Discord Community!
Stuck on a problem, or don't understand a module? Join the Discord and get help with your doubts while making more math friends.
