# GCD / LCM

The greatest common divisor of a set of integers is the largest number that divides each integer in the set. We denote the greatest common divisor by $\gcd(a, b, \ldots)$. We can attempt to find this value by listing all divisors of the integers and finding the largest divisor. However, such a procedure can get tedious.

If we know the prime factorization, then there is a simpler approach. If the prime factorizations of $a$ and $b$ are

\begin{aligned} a & = p_1 ^{\alpha_1} p_2 ^{\alpha_2} \ldots p_k ^{\alpha_k}, \\ b & = p_1 ^{\beta_1} p_2 ^ {\beta_2} \ldots p_k ^ {\beta_k}, \\ \end{aligned}

then the GCD of the numbers is equal to

$\gcd(a,b) = p_1 ^{\min(\alpha_1, \beta_1)} p_2 ^{\min(\alpha_2, \beta_2)} \ldots p_k ^{\min(\alpha_k, \beta_k)} .$

A similar formula holds for finding the GCD of several integers, by taking the smallest exponent for each prime.

Similarly, the least common multiple of a set of integers is the smallest (positive) number which is a multiple of each integer in the set. We denote this value as $\mbox{lcm}(a, b, \ldots)$. We can attempt to find this value by listing all multiples of the integers in the set, and then finding the one which is the smallest.

However, as above, if we know the prime factorization, then computing the least common multiple is much simpler:

$\mbox{lcm}(a,b) = p_1 ^{\max(\alpha_1, \beta_1)} p_2 ^{\max(\alpha_2, \beta_2)} \ldots p_k ^{\max(\alpha_k, \beta_k)}.$

Note: Another approach to find the GCD of 2 numbers is through the Euclidean Algorithm.

## Worked Examples

### 1. Show that the GCD of 2 numbers is indeed equal to

$G = p_1 ^{\min(\alpha_1, \beta_1)} p_2 ^{\min(\alpha_2, \beta_2)} \ldots p_n ^{\min(\alpha_n, \beta_n)} .$

Solution: Clearly, $G$ is a divisor of both $a$ and $b$, and so $G \leq \gcd(a,b)$.

We will now show that there is no greater common divisor, by considering the prime factorization of $\gcd(a,b)$. Any prime divisor of $\gcd(a,b)$ is also a prime divisor of $a$ and $b$. Hence, it is sufficient for us to simply consider the primes that divide $a$ or $b$.

Given any prime $p_i$ that divides $a$ or $b$, let $p_i ^ {\alpha_i}$ and $p_i ^{\beta_i}$ be the largest powers of $p$ that divide $a$ and $b$ respectively. Note that we could have $\alpha_i, \beta_i = 0$. Clearly, $p^{\min(\alpha_i, \beta_i) } \mid a$ and $p^{\min(\alpha_i, \beta_i) } \mid b$, hence $p^{\min(\alpha_i, \beta_i) } \mid \gcd(a,b)$. Furthermore, since $p^{\min(\alpha_i, \beta_i) +1 }$ does not divide either $a$ or $b$ by construction, thus $p^{\min(\alpha_i, \beta_i) +1 }$ does not divide $\gcd(a,b)$. Hence, $\gcd (a,b) \leq G$.

As such, we have $\gcd(a,b) = G$.

Note: You can use a similar method to prove the claim for $\mbox{lcm}(a,b)$.

### 2. Show that $\gcd(a,b) \times \mbox{lcm}(a,b) = a \times b$.

First, we show that $m+ n = \min(m,n) + \max (m,n)$. Without loss of generality, $n\leq m$. Hence, $\min (m,n) = n$ and $\max(m,n) = m$, thus $m + n = \min(m,n) + \max (m,n)$.

Applying this to each of the pairs $m = \alpha_i, n = \beta _i$, we get that

$a \times b = \prod_{i=1}^k p_i ^{\alpha_i + \beta_i } = \prod_{i=1}^k p_i ^ { \min(\alpha_i, \beta_i) + \max(\alpha_i , \beta_i)} = \gcd(a,b) \times \mbox{lcm}(a,b).$

### 3. Given that $a$ and $b$ are 2 integers such that $13 \gcd(a,b) = \mbox{lcm}(a,b)$ and $a + b = 2016$, what are the values of $a$ and $b$?

Let $G = \gcd(a,b)$ and $L = \mbox{lcm}(a,b)$.
Let $a = a^* G$ and $b = b^* G$ where $\gcd(a^*, b^*) = 1$ by construction. Since $(a^*G)\times (b^*G) = ab = GL = G \times 13 G$, we get that $a^* b^* = 13$. Hence, we have $\{ a^*, b^* \} = \{ 1, 13\}$. WLOG, we may assume that $a\leq b$, and thus $a = G, b = 13 G$.

Since $2016 = a + b = G + 13G = 14 G$, thus $G = \frac{2016} { 14} = 144$. Thus, $\{a, b\} = \{ 144, 1872 \}$. Note by Arron Kau
6 years, 8 months ago

This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.

When posting on Brilliant:

• Use the emojis to react to an explanation, whether you're congratulating a job well done , or just really confused .
• Ask specific questions about the challenge or the steps in somebody's explanation. Well-posed questions can add a lot to the discussion, but posting "I don't understand!" doesn't help anyone.
• Try to contribute something new to the discussion, whether it is an extension, generalization or other idea related to the challenge.

MarkdownAppears as
*italics* or _italics_ italics
**bold** or __bold__ bold
- bulleted- list
• bulleted
• list
1. numbered2. list
1. numbered
2. list
Note: you must add a full line of space before and after lists for them to show up correctly
paragraph 1paragraph 2

paragraph 1

paragraph 2

[example link](https://brilliant.org)example link
> This is a quote
This is a quote
    # I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
# I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
MathAppears as
Remember to wrap math in $$ ... $$ or $ ... $ to ensure proper formatting.
2 \times 3 $2 \times 3$
2^{34} $2^{34}$
a_{i-1} $a_{i-1}$
\frac{2}{3} $\frac{2}{3}$
\sqrt{2} $\sqrt{2}$
\sum_{i=1}^3 $\sum_{i=1}^3$
\sin \theta $\sin \theta$
\boxed{123} $\boxed{123}$

Sort by:

From where do you get so much information???

- 6 years, 4 months ago

Books. E.g. Introduction to number theory by CJ Bradley (from UKMT) or Elementary Number Theory by Jones (yellow book).

- 6 years ago

@Arron Kau What is the least $\normalsize lcm$ of $n$ numbers adding upto $m$. Do we have a subjective approach for it?

- 6 years, 4 months ago

thanks.............

- 6 years, 4 months ago