Chapter

GCD, LCM and Euclidean Algorithm

The module turns computational GCD into an olympiad tool: Euclid's algorithm, linear combinations, GCDs of expressions, the GCD-LCM relation, coprimality, and numbers of the form \(a^m-1\).
Log in to track solved progress and bookmarks.

Theory

Key Idea

The GCD measures the common part of two numbers, while the LCM is the smallest number containing both structures as divisors. In olympiad problems, the GCD is not just something to compute; common divisors can be moved between expressions.

The Euclidean algorithm is based on \(\gcd(a,b)=\gcd(b,a-b)\), and more strongly on \(\gcd(a,b)=\gcd(b,r)\), where \(r\) is the remainder when \(a\) is divided by \(b\).

Basic Facts

  • \(\gcd(a,b)\operatorname{lcm}(a,b)=ab\) for positive \(a,b\).
  • If \(d=\gcd(a,b)\), then \(a=dx\), \(b=dy\), where \(\gcd(x,y)=1\).
  • \(\gcd(a,b)=\gcd(a,b-a)=\gcd(b,a\bmod b)\).
  • If \(\gcd(a,b)=1\) and \(a\mid bc\), then \(a\mid c\).
  • A common divisor of two expressions divides every integer linear combination of them.
  • For \(a>1\): \(\gcd(a^m-1,a^n-1)=a^{\gcd(m,n)}-1\).

When to Use This Method

  • You need to find a common divisor of two expressions with a parameter.
  • The problem contains both a GCD and an LCM.
  • You need to reduce a large pair of numbers without prime factorising them.
  • Numbers of the form \(a^m-1\) and \(a^n-1\) appear.
  • You need to prove that two expressions are coprime.

How to Recognise the Method

If two expressions depend on \(n\), try subtracting one from the other or forming a linear combination to lower the degree. Often the GCD divides a small constant.

If the GCD and LCM of two numbers are given, write \(a=dx\), \(b=dy\), \(\gcd(x,y)=1\). Then the LCM is \(dxy\).

Typical Mistakes

  • Computing the GCD of large numbers by factorisation when Euclid is shorter.
  • Using \(ab=\gcd(a,b)\operatorname{lcm}(a,b)\) for three numbers, where it is false.
  • After writing \(a=dx\), \(b=dy\), forgetting the condition \(\gcd(x,y)=1\).
  • Cancelling in a divisibility or congruence without checking coprimality.
  • For \(a^m-1\), expanding powers instead of applying Euclid to the exponents.

Mini-Checklist

  • Can the pair \((a,b)\) be replaced by \((b,a-b)\) or \((b,r)\)?
  • Can you form a small linear combination of the expressions?
  • If GCD and LCM are known, have you written \(a=dx\), \(b=dy\)?
  • Have you checked that the remaining parts are coprime?
  • For powers \(a^m-1\), can the Euclidean algorithm be applied to the exponents?

Examples

Example 1. The Euclidean Algorithm

We learn to reduce a pair of numbers without full factorisation.

Problem. Find \(\gcd(252,198)\).

Solution.

\(\gcd(252,198)=\gcd(198,54)=\gcd(54,36)=\gcd(36,18)=18\). The answer is \(18\).

Comment. At each step, replace the larger number by its remainder upon division by the smaller one.

Example 2. GCD and LCM by Prime Powers

Minimum and maximum exponents give the GCD and LCM.

Problem. Find \(\gcd(84,126)\) and \(\operatorname{lcm}(84,126)\).

Solution.

\(84=2^2\cdot3\cdot7\), \(126=2\cdot3^2\cdot7\). Therefore \(\gcd(84,126)=2\cdot3\cdot7=42\), while \(\operatorname{lcm}(84,126)=2^2\cdot3^2\cdot7=252\).

Comment. The GCD takes smaller exponents; the LCM takes larger ones.

Example 3. Given the GCD and LCM

The relation \(ab=\gcd(a,b)\operatorname{lcm}(a,b)\) often finds an unknown number immediately.

Problem. Find \(n\) if \(\gcd(n,70)=14\) and \(\operatorname{lcm}(n,70)=420\).

Solution.

For two positive numbers, \(n\cdot70=\gcd(n,70)\operatorname{lcm}(n,70)\). Hence \(70n=14\cdot420\), so \(n=84\). Check: \(\gcd(84,70)=14\), \(\operatorname{lcm}(84,70)=420\).

Comment. The formula applies to exactly two numbers.

Example 4. GCD of Expressions with a Parameter

A common divisor often divides a small constant.

Problem. Prove that \(\gcd(n^2+1,n+3)\) divides \(10\).

Solution.

Let \(d=\gcd(n^2+1,n+3)\). Then \(n\equiv -3\pmod d\), so \(n^2+1\equiv 9+1=10\pmod d\). Since \(d\mid n^2+1\), we get \(d\mid10\).

Comment. This is the main move for problems of the form \(\gcd(f(n),g(n))\).

Example 5. Coprimality of Consecutive Integers

The simplest example of a GCD equal to one.

Problem. Prove that \(\gcd(n,n+1)=1\).

Solution.

Any common divisor of \(n\) and \(n+1\) divides their difference \((n+1)-n=1\). Hence the only possible common divisor is \(1\).

Comment. The difference of consecutive numbers is the shortest route.

Example 6. Division Under Coprimality

This is one of the most frequently used facts in number theory.

Problem. Let \(\gcd(a,b)=1\) and \(a\mid bc\). Prove that \(a\mid c\).

Solution.

All prime factors of \(a\) are absent from \(b\), since \(\gcd(a,b)=1\). But \(bc\) is divisible by \(a\), so all prime factors of \(a\), with their needed powers, must occur in \(c\). Therefore \(a\mid c\).

Comment. Later this becomes a precise tool in congruences.

Example 7. Powers Minus One

The Euclidean algorithm can be applied to exponents.

Problem. Find \(\gcd(2^{18}-1,2^{30}-1)\).

Solution.

Use \(\gcd(a^m-1,a^n-1)=a^{\gcd(m,n)}-1\). Since \(\gcd(18,30)=6\), we get \(2^6-1=63\).

Comment. The formula can be proved by Euclid: \(a^m-1\) is divisible by \(a^d-1\) when \(d\mid m\).

Example 8. GCD of Repeated Blocks

Sometimes the GCD of a whole family is visible from a common factor.

Problem. Find the GCD of all six-digit numbers of the form \(\overline{abcabc}\).

Solution.

Such a number equals \(1000\cdot\overline{abc}+\overline{abc}=1001\cdot\overline{abc}\). Hence all such numbers are divisible by \(1001\). On the other hand, among three-digit blocks there are coprime ones, for example \(100\) and \(101\), so no extra common factor is forced. The GCD of the whole family is \(1001\).

Comment. This is not a computation for one pair, but a GCD of a family.

Problems

Problems

#2.1
#2.1

Euclid for Two Numbers

GCD Grade 7 Grade 8 ★☆☆☆☆

Find \(\gcd(252,198)\) using the Euclidean algorithm.

Details
Problem: NT-B1-M02-P001
Difficulty: Level 1 of 5
Tag: GCD
Grade: Grade 7, Grade 8
#2.2
#2.2

GCD and LCM of 84 and 126

GCD Grade 7 Grade 8 ★☆☆☆☆

Find \(\gcd(84,126)\) and \(\operatorname{lcm}(84,126)\).

Details
Problem: NT-B1-M02-P002
Difficulty: Level 1 of 5
Tag: GCD
Grade: Grade 7, Grade 8
#2.3
#2.3

Product of GCD and LCM

GCD Grade 7 Grade 8 ★☆☆☆☆

Let \(a=96\), \(b=180\). Verify \(ab=\gcd(a,b)\operatorname{lcm}(a,b)\).

Details
Problem: NT-B1-M02-P003
Difficulty: Level 1 of 5
Tag: GCD
Grade: Grade 7, Grade 8
#2.4
#2.4

Consecutive Numbers

Coprime Grade 7 Grade 8 ★☆☆☆☆

Prove that \(\gcd(n,n+1)=1\) for every integer \(n\).

Details
Problem: NT-B1-M02-P004
Difficulty: Level 1 of 5
Tag: Coprime
Grade: Grade 7, Grade 8
#2.5
#2.5

GCD with a Linear Expression

GCD Grade 7 Grade 8 ★☆☆☆☆

Prove that \(\gcd(n,2n+1)=1\) for every integer \(n\).

Details
Problem: NT-B1-M02-P005
Difficulty: Level 1 of 5
Tag: GCD
Grade: Grade 7, Grade 8
#2.6
#2.6

A Common Factor \(n\)

GCD Grade 8 Grade 9 ★★☆☆☆

For positive \(n\), find \(\gcd(48n,180n)\) and \(\operatorname{lcm}(48n,180n)\).

Details
Problem: NT-B1-M02-P006
Difficulty: Level 2 of 5
Tag: GCD
Grade: Grade 8, Grade 9
#2.7
#2.7

Recover the Number

GCD Grade 8 Grade 9 ★★☆☆☆

Find positive \(n\) if \(\gcd(n,90)=18\) and \(\operatorname{lcm}(n,90)=630\).

Details
Problem: NT-B1-M02-P007
Difficulty: Level 2 of 5
Tag: GCD
Grade: Grade 8, Grade 9
#2.8
#2.8

Numbers Two Apart

GCD Grade 8 Grade 9 ★★☆☆☆

Prove that \(\gcd(n,n+2)\) divides \(2\). Determine this GCD for even and odd \(n\).

Details
Problem: NT-B1-M02-P008
Difficulty: Level 2 of 5
Tag: GCD
Grade: Grade 8, Grade 9
#2.9
#2.9

Quadratic and \(n\)

Coprime Grade 8 Grade 9 ★★☆☆☆

Prove that \(\gcd(n^2+n+1,n)=1\) for every positive \(n\).

Details
Problem: NT-B1-M02-P009
Difficulty: Level 2 of 5
Tag: Coprime
Grade: Grade 8, Grade 9
#2.10
#2.10

Sum and Difference

Coprime Grade 8 Grade 9 ★★☆☆☆

Let \(\gcd(a,b)=1\). Prove that \(\gcd(a+b,a-b)\) divides \(2\).

Details
Problem: NT-B1-M02-P010
Difficulty: Level 2 of 5
Tag: Coprime
Grade: Grade 8, Grade 9
#2.11
#2.11

When the GCD Is Greater Than One

GCD Grade 8 Grade 9 ★★☆☆☆

Find all integers \(n\) for which \(\gcd(n+2,n^2+3n+5)>1\).

Details
Problem: NT-B1-M02-P011
Difficulty: Level 2 of 5
Tag: GCD
Grade: Grade 8, Grade 9
#2.12
#2.12

GCD and LCM with 36

GCD Grade 8 Grade 9 ★★☆☆☆

Find positive \(n\) if \(\gcd(n,36)=12\) and \(\operatorname{lcm}(n,36)=180\).

Details
Problem: NT-B1-M02-P012
Difficulty: Level 2 of 5
Tag: GCD
Grade: Grade 8, Grade 9
#2.13
#2.13

Sum and Product

Coprime Grade 8 Grade 9 ★★★☆☆

Let \(\gcd(a,b)=1\). Prove that \(\gcd(a+b,ab)=1\).

Details
Problem: NT-B1-M02-P013
Difficulty: Level 3 of 5
Tag: Coprime
Grade: Grade 8, Grade 9
#2.14
#2.14

GCD of \(n^2+1\) and \(n+3\)

GCD Grade 8 Grade 9 ★★★☆☆

Find all integers \(n\) for which \(\gcd(n^2+1,n+3)>1\).

Details
Problem: NT-B1-M02-P014
Difficulty: Level 3 of 5
Tag: GCD
Grade: Grade 8, Grade 9
#2.15
#2.15

The GCD Divides 3

GCD Grade 8 Grade 9 ★★★☆☆

Prove that \(\gcd(n^2+n+1,n-1)\mid3\). When is this GCD equal to \(3\)?

Details
Problem: NT-B1-M02-P015
Difficulty: Level 3 of 5
Tag: GCD
Grade: Grade 8, Grade 9
#2.16
#2.16

GCD of Two Mersenne-Type Numbers

GCD Grade 9 Grade 10 ★★★☆☆

Find \(\gcd(2^{18}-1,2^{30}-1)\).

Details
Problem: NT-B1-M02-P016
Difficulty: Level 3 of 5
Tag: GCD
Grade: Grade 9, Grade 10
#2.17
#2.17

Powers of Coprime Numbers

Coprime Grade 9 Grade 10 ★★★☆☆

Prove: if \(\gcd(a,b)=1\), then \(\gcd(a^m,b^n)=1\) for all positive \(m,n\).

Details
Problem: NT-B1-M02-P017
Difficulty: Level 3 of 5
Tag: Coprime
Grade: Grade 9, Grade 10
#2.18
#2.18

Sum of Squares and Sum

Coprime Grade 9 Grade 10 ★★★☆☆

Let \(\gcd(a,b)=1\). Prove that \(\gcd(a^2+b^2,a+b)\mid2\).

Details
Problem: NT-B1-M02-P018
Difficulty: Level 3 of 5
Tag: Coprime
Grade: Grade 9, Grade 10
#2.19
#2.19

Another Parameter GCD

GCD Grade 9 Grade 10 ★★★☆☆

Find all positive \(n\) such that \(\gcd(n^2+4,n+6)>1\).

Details
Problem: NT-B1-M02-P019
Difficulty: Level 3 of 5
Tag: GCD
Grade: Grade 9, Grade 10
#2.20
#2.20

GCD of Two Shifted Expressions

GCD Grade 9 Grade 10 ★★★☆☆

Find the exact value of \(\gcd(n^2+n+1,n^2+2n+3)\) depending on the integer \(n\).

Details
Problem: NT-B1-M02-P020
Difficulty: Level 3 of 5
Tag: GCD
Grade: Grade 9, Grade 10
#2.21
#2.21

General Formula for \(a^m-1\)

GCD Grade 9 Grade 10 ★★★★☆

Prove that for integer \(a>1\) and positive \(m,n\),

\[\gcd(a^m-1,a^n-1)=a^{\gcd(m,n)}-1.\]

Details
Problem: NT-B1-M02-P021
Difficulty: Level 4 of 5
Tag: GCD
Grade: Grade 9, Grade 10
#2.22
#2.22

Pairs with Given GCD and LCM

Coprime Grade 9 Grade 10 ★★★★☆

Find all unordered pairs of positive integers \((a,b)\) such that \(\gcd(a,b)=12\) and \(\operatorname{lcm}(a,b)=720\).

Details
Problem: NT-B1-M02-P022
Difficulty: Level 4 of 5
Tag: Coprime
Grade: Grade 9, Grade 10
#2.23
#2.23

Cubes with Required Divisibility

GCD Grade 9 Grade 10 ★★★★☆

Three positive perfect cubes are divisible by \(18\). What is the smallest possible value of their common GCD?

Details
Problem: NT-B1-M02-P023
Difficulty: Level 4 of 5
Tag: GCD
Grade: Grade 9, Grade 10
Source: Method inspiration: local number theory source
#2.24
#2.24

Sum and LCM

Coprime Grade 9 Grade 10 ★★★★★

Find two positive integers \(a,b\) if \(a+b=154\) and \(\operatorname{lcm}(a,b)=840\).

Details
Problem: NT-B1-M02-P024
Difficulty: Level 5 of 5
Tag: Coprime
Grade: Grade 9, Grade 10
Source: Method inspiration: local number theory source

Ladders

No published ladders were found.
Previous Chapter
Next Chapter