Skip to main content

Coprimality in Lowest Common Multiple

· 3 min read

Suppose that we select arbitrarily a number of, say, nn integers, denoted by a1,,ana_1, \ldots, a_n. If we obtain their lowest common multiple (LCM), and label it as M:=lcm(a1,,an)M := \mathrm{lcm}(a_1,\ldots,a_n), then take for each of the initial nn integers the corresponding number kik_i (i=1,,ni = 1, \ldots, n) such that multiplying by that number gives us the LCM, i.e. kiai=Mk_i a_i = M for each ii, an intriguing pattern starts to emerge: all the numbers kik_i are coprime, i.e. gcd(k1,,kn)=1\gcd(k_1,\ldots,k_n)=1.

The following is an example code snippet that illustrates this phenomenon. This snippet generates a list of nn random integers between 00 and KK, obtains their LCM, extract the factor kik_i for each of aia_i, where i=1,,ni = 1, \ldots, n, from the LCM and calculate the greatest common divisor (GCD) of the kik_i's.

Repeatedly running this code generates a different group of nn integers, but notice that the GCD obtained in the end is always 1.

The definitions of lcm_euclidean_general and gcd_euclidean_general in the snippet can be found in this note.

from random import randint
n, K = 4, 2000 # feel free to change the parameters here
test = [randint(0, K) for i in range(n)]
lcm = lcm_euclidean_general(*test)
smallest_k = tuple(map(lambda x: lcm // x, test))
print(gcd_euclidean_general(*smallest_k)) # 1

Why though?

To those who are familiar with the topic of coprime integers, this phenomenon should not come as a surprise. Nevertheless, a brief explanation of this fact will be presented here.

If we assume that the numbers kik_i, where i=1,,ni = 1,\ldots,n are not coprime, or equivalently gcd(k1,,kn)>1\gcd(k_1,\ldots,k_n) > 1, and we call the GCD to be GG, then we can write ki=Gbik_i=Gb_i where bib_i is an integer and G>1G>1. It follows that M=GbiaiM=Gb_ia_i for each ii.

However, this also means that we can divide each of them throughout by GG and obtain MG=biai\frac{M}{G}=b_ia_i for each ii. Note that MG<M\frac{M}{G} < M because M>0M > 0 and G>1G > 1, and is a constant integer because GG is also a common factor of MM. Note as well that since each bib_i is an integer, this means that MG\frac{M}{G} is a common multiple of the aia_i's that is smaller than the lowest common multiple MM? This does not make sense, right? This is where we reach a (logical) contradiction for which the only way to resolve this is to conclude that the GCD GG cannot be greater than 1 all along, thus the kik_i's from the start must be coprime!

We have thus demonstrated the technique of proof by contradiction to confirm the validity of this fact.

That's all for this post. Hopefully this fact sounds cool enough to you and prompts you to learn more about factors and multiples of integers, or even elementary number theory in general.