GCD to LCM of multiple numbers

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?


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).


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{align}{\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{align}$

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

Remark $\ $ 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.


$$\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".


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)))$.