Sign up ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

If I know the GCD of 20 numbers, and know the 20 numbers, is there a formula such that I input the 20 numbers and input their GCD, and it outputs their LCM? I know that $$\frac{\left| a\cdot b\right|}{\gcd(a,b)} = \text{lcm}(a,b).$$ So is it$$\frac{\left| a\cdot b\cdot c\cdot d\cdot e\cdot f\right|}{\gcd(a,b,c,d,e,f)}?$$If not, what is it?

share|cite|improve this question

8 Answers 8

up vote 8 down vote accepted

There can be no formula that computes $\text{lcm}(a,b,c)$ using only the values of $abc$ and $\gcd(a,b,c)$ as input: that's because $(a,b,c) = (1,2,2)$ and $(a,b,c) = (1,1,4)$ both have $abc=4$, $\gcd(a,b,c)=1$, but they don't have the same lcm.

However, there is a straightforward generalization of the $2$-variable formula. For instance, $$\text{lcm}(a,b,c,d) = \frac{abcd}{\gcd(abc,abd,acd,bcd)}.$$

The correct gcd to take is not of the individual terms $a,b,c,d$ but the products of all the complementary terms (which looks the same in the two-variable case).

share|cite|improve this answer
See my answer for a simple proof. –  Math Gems Mar 3 '13 at 18:56

As mentioned, it does not generalize like that. But there do exist generalizations. For example, using the standard gcd notation $\rm\ (x,y,\ldots)\, :=\, gcd(x,y,\ldots),\:$ we have

Theorem $\rm\,\ lcm(a,b,c)\, =\, \dfrac{abc}{(bc,ca,ab)}$

$\begin{eqnarray}{\bf Proof}\qquad\qquad\rm\ a,b,c&\mid&\rm\ n\\ \iff\quad\rm abc&\mid&\rm\,\ nbc,nca,nab\\ \iff\quad\rm abc&\mid&\rm (nbc,nca,nab)\, =\, n(bc,ca,ab)\\ \iff\rm\ \ \dfrac{abc}{(bc,ca,ab)}\ \Bigg|\!\!\!\!\!&&\rm\ n\end{eqnarray}$

Hence the claimed equality follows by the (universal) definition of lcm. $\ \ $ QED

Remark $\ $ Notice the penultimate equivalence in the proof uses said (universal) definition of gcd, followed by the gcd distributive law. An analogous proof works for any number of arguments.

share|cite|improve this answer
This was fine as posted: $(a,b,c)$ is a standard notation for the greatest common divisor of $a,b$, and $c$. –  Brian M. Scott Mar 3 '13 at 19:03

It certainly doesn't work like that. Consider that $\gcd(1, 2, 2) = 1$, $\text{lcm}(1, 2, 2) = 2$ and $1 \times 2 \times 2 = 4$.

A good way to think of this is to consider a natural number $n$ as a vector which has $x$ for $i$th component if $x$ is the largest power of $i$th prime, dividing $n$. For example, $50 = 2\times 5^2$ would be $(1, 0, 2, 0, 0 \dots)$. Then $\gcd$ is a componentwise $\min$, $\text{lcm}$ is a componentwise $\max$ and $\times$ is a componentwise $+$. It just so happens that for two numbers, $\min(a, b) + \max(a, b) = a+b$. Same is not true for three or more numbers.

Using the same interpretation, you can construct many other similar formulas though. For example, $\text{lcm}(a, b, c, \dots) = \text{lcm}(a, \text{lcm}(b, \text{lcm}(c, \dots)))$.

share|cite|improve this answer

$$\operatorname{lcm}(a,b)=\frac{a\cdot b}{\operatorname{gcd}(a,b)};$$ $$\operatorname{lcm}(a,b,c)=\frac{a\cdot b\cdot c\cdot \operatorname{gcd}(a,b,c)}{\operatorname{gcd}(a,b)\cdot \operatorname{gcd}(a,c)\cdot \operatorname{gcd}(b,c)};$$ $$\operatorname{lcm}(a,b,c,d)=\frac{a\cdot b\cdot c\cdot d\cdot\operatorname{gcd}(a,b,c)\cdot\operatorname{gcd}(a,b,d)\cdot\operatorname{gcd}(a,c,d)\cdot\operatorname{gcd}(b,c,d)}{\operatorname{gcd}(a,b)\cdot\operatorname{gcd}(a,c)\cdot\operatorname{gcd}(a,d)\cdot\operatorname{gcd}(b,c)\cdot\operatorname{gcd}(b,d)\cdot\operatorname{gcd}(c,d)\cdot\operatorname{gcd}(a,b,c,d)};$$ etc. This is because $$\max(a,b)=a+b-\min(a,b);$$ $$\max(a,b,c)=a+b+c-\min(a,b)-\min(a,c)-\min(b,c)+\min(a,b,c);$$ $$\max(a,b,c,d)=a+b+c+d-\min(a,b)-\min(a,c)-\min(a,d)-\min(b,c)-\min(b,d)-\min(c,d)+\min(a,b,c)+\min(a,b,d)+\min(a,c,d)+\min(b,c,d)-\min(a,b,c,d);$$ etc. This is the "in-and-out" principle, aka "The Principle of Inclusion and Exclusion".

share|cite|improve this answer

If you are asking whether the identity $\dfrac{|a_1a_2\cdots a_n|}{\gcd(a_1,a_2,\ldots,a_n)}=\text{lcm}(a_1,a_2,\ldots,a_n)$ is true for $n>2$ then the answer is no.
Take for example $n=3, a_1=2, a_2=4,a_3=3$.

share|cite|improve this answer

LCM(a,b,c,d...) depends on the prime factors of each of a,b,c,d,... You can't determine that from abcd.. and GCD(a,b,c,d...). Example: a,b,c=(p1p2),(p1p3),(p1p2p3) abc=(p1^3)(p2^2)(p3^2), GCD=p1, LCM=(p1)(p2)(p3)

a,b,c=(p1),(p1p2),(p1p2p3^2) abc=(p1^3)(p2^2)(p3^2), GCD=p1, LCM=(p1)(p2)(p3^2)

p1,p2,p3,... are primes

share|cite|improve this answer
This doesn't appear the way I typed it, which was clearer. Don't know how to correct it. –  hartlw Apr 3 at 5:40


Proof. Every CM of a,b,c,d,.. is a CM of LCM(a,b),c,d,.. and every CM of LCM(a,b),c,d,.. is a CM of a,b,c,d,..

The same proof holds for any grouping like LCM(a,b,c,d,e)=LCM(LCM(a,b,c),LCM(d,e)).

Examples: LCM(a,b,c,d)=LCM(e,f)
e=LCM(a,b), f=LCM(c,d), and LCM(e,f)=ef/GCD(e,f)


If you substitute you get
LCM(a,b,c,d)=LCM(LCM(LCM(a,b),c),d) given in, in case you were wondering.

share|cite|improve this answer

LCM can be calculated using:
$\text{GCD}(a,b)\cdot \text{LCM}(a,b)=ab$ and


or more concisely $$ \begin{align} 2&,4,5,7 \\ 4&,5,7 \\ 20&,7 \\ 140& \end{align} $$

share|cite|improve this answer
LCM(a,b,c,d...)=LCM(LCM(a,b),c,d,...) –  hartlw Apr 2 at 17:57
The previous comment is incomplete because as soon as I hit enter to start a new line my comment is submitted, incomplete. –  hartlw Apr 2 at 18:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.