Greatest common divisor and least common multiple

A species of cicada that lives in North America, the magicicada, had a peculiar evolutionary path, in which prime numbers played a fundamental role for survival. So, how can prime numbers give help to this formidable insect?

A flying swarm of magicicadas

What’s the greatest common divisor (GCD)?

The greatest common divisor, shortened by the acronym GCD is, as the name itself says, the greatest possible divisor in common among two or more integer numbers.

For example, both 12 and 16 are divisible by 2 because they are both even, but 2 is not the greatest divisor of both.

After a quick calculation, in fact, we can see that they are also divisible by 4, since the respective divisions give as results integer numbers:

\frac{\displaystyle 12}{\displaystyle 4} = 3
\frac{\displaystyle 16}{\displaystyle 4} = 4

By other trials, we can check that there aren’t numbers greater than 4 that are divisors of both. So 4 is said to be the greatest common divisor of 12 and 16.

Such a result can be expressed in a concise form as GCD(12, 16) = 4.
We can note that the GCD is not necessarily a prime number, but it’s the greatest divisor of both numbers. Remember that a divisor is a number such that, when a given number is divided by it, the result is a non-decimal number; for example 3 is a divisor of 6 (6/3 = 2), whereas 4 is not (6/4 = 1.5).

But trying to compute the greatest common divisor by trials is an uneffected and expensive method, if we have large numbers.

The most effective method for doing this calculation is decomposing into prime factor the numbers which we want to compute the greatest common divisor of, and multiplying the common prime factors, taken once, powered to the least exponent.

When a common prime factor has no exponent, it’s implicitly equal to 1.
What is the greatest common divisor of 14 and 21? I.e., what is GCD(14, 21)?

Let’s start from factorizing both numbers in order to find the common prime factors. By a quick factorization we’ll obtain that:

14 = 2 \cdot 7
21 = 3 \cdot 7

We can note how both numbers have in their factorizations the number 7, which has exponent 1 in both. The other prime factors are not common. So, 7 is the greatest common divisor of both:

GCD(14, 21) = 7
What is the greatest common divisor of 12 and 40, i.e. GCD(12, 40)?

Let’s start by factorizing both numbers in order to find the common prime factors. By doing a quick decomposition into prime factors we’ll obtain that:

12 = 2 \cdot 2 \cdot 3 = 2^2 \cdot 3
40 = 2 \cdot 2 \cdot 2 \cdot 5 = 2^3 \cdot 5

In this situation, both numbers have the common number 2 in their factorization.

However we can note that in 12 it appears twice (the exponent is 2), while in 40 it appears three times (the exponent is 3). So the least exponent for this factor is 2.

In order to compute the greatest common divisor we have to compute the product of the common factors (the ones which appears in both factorizations), but with the least exponent. In this case the only common factor is 2, and its least exponent is 2, so:

GCD (12, 40) = 2^2 = 4
What is the greatest common divisor of 270 and 1008, i.e. GCD(270, 1008)?

Let’s start from factorizing both numbers in order to find the common prime factors:

270 = 2 \cdot 3 \cdot 3 \cdot 3 \cdot 5 = 2 \cdot 3^3 \cdot 5
1008 = 2 \cdot 2 \cdot 2 \cdot 2 \cdot 3 \cdot 3 \cdot 7 = 2^4 \cdot 3^2 \cdot 7

The numbers have two common prime factors:

  • The first is 2. In 270 the exponent is not indicated, so it’s 1, while in 1008 it’s 4; the least exponent is 1, so the first factor of the GCD is 2.
  • The second is 3. In 270 it has exponent 3, while in 504 it has exponent 2; the least exponent is 2, so the second factor of the GCD is 3^2.

Let’s multiply the factors we have found: we’ll obtain 2 \cdot 3^2 = 2 \cdot 4 = 8, so:

GCD(270, 1008) = 8
Definition:

If the least common multiple between two or more numbers is 1, they are said to be relatively prime, or coprime.

What is GCD(75, 195)?

Let’s decompose both numbers into prime factors:

75 = 3 \cdot 5 \cdot 5 = 3 \cdot 5^2
195 = 3 \cdot 5 \cdot 13

The divisors 3 and 5 appear in both factorizations. Though 5 appears twice in the factorization of 75, it appears only once in the one of 195.

So:

GCD(75, 195) = 3 \cdot 5 = 15

Remember that that by divisor we mean a number such that, when the given number is divided by it, the result is an integer number. In fact:

\frac{\displaystyle 75}{\displaystyle 15} = 5
\frac{\displaystyle 195}{\displaystyle 15} = 13

What is the least common multiple (lcm)?

The least common multiple, shortened by the acronym lcm, is the smallest common multiple between two or more integer numbers.

For example, let’s try to compute the least common multiple between 10 and 15. By definition, we have to find the smallest of the common multiples, so let’s start from listing the multiples of the two numbers, up to finding some in common:

Multiples of 10 are 10 itself, 20, 30, 40, 50, 60, 70, 80, 90 and so on.
Multiples of 15 are 15 itself, 30, 45, 60, 75, 90 and so on.

We can note that the first common multiple which appears in these two sequences is 30, Other common multiples are 60 e 90 (and we’d have found others if we had proceeded), but we are looking for the smallest one. So 30 is the least common multiple for 10 and 15.

This result is expressed by the notation lcm(10, 15) = 30.

Computing the multiples of two or more numbers up to bumping into a common one is an operation that can take a long time.

The most effective method for doing this calculation is to decompose into prime factors the numbers which we want to compute the least common multiple of, and then multiplying the common and non-common prime factors, each taken once, powered to the biggest exponent.

Like for the greatest common divisor, when a prime factor has no exponent at all, it’s implicit and it’s equal to 1.
Let’s compute the least common multiple between 18 and 30.

Let’s start from factorizing both numbers in order to find the prime factors. Doing a quick decomposition into prime factors we’ll obtain:

18 = 2 \cdot 3^2
30 = 2 \cdot 3 \cdot 5

In order to find the least common multiple, we have to consider common and non-common prime factors, taken only once, but this time with the biggest exponent. The overall prime factors of the two numbers, both common and non-common, are the following:

  • 2 is common; it has exponent 1 for both given numbers, so the biggest exponent is 1.
  • 3 is common; it has exponent 2 for 18, and exponent 1 for 30, so its biggest exponent is 2.
  • 5 is a divisor of 30 only.

We can deduce that the least common multiple, shortened with lcm, is:

lcm(18, 30) = 2 \cdot 3^2 \cdot 5 = 2 \cdot 9 \cdot 5 = 90

This means that 90 is the smallest possible number which is divisible both by 18 and by 30.

What is lcm(45, 105)?

Let’s decompose both numbers into prime factors:

45 = 3 \cdot 3 \cdot 5 = 3^2 \cdot 5
105 = 3 \cdot 5 \cdot 7

Now let’s consider the product of all prime factors taken once with the biggest exponent. The solution is:

lcm(45, 105) = 3^2 \cdot 5 \cdot 7 = 315

An useful property

There is another way to compute the least common multiple if we have already computed the greatest common divisor, or vice versa. We can in fact use these relationships:

GCD(a, b) = \frac{\displaystyle a \cdot b}{\displaystyle lcm(a, b)}
lcm(a, b) = \frac{\displaystyle a \cdot b}{\displaystyle GCD(a, b)}
Let’s consider a = 10 and b = 15.

In a previous example, we have already computed lcm(10, 1 5) = 30.

Now let’s compute the product a \cdot b, i.e. 10 \cdot 15 = 150.

Using the first property just stated, we can obtain that the greatest common multiple between the two numbers is:

GCD(10, 15) = \frac{\displaystyle 10 \cdot 15}{\displaystyle lcm(10, 15)} = \frac{\displaystyle 150}{\displaystyle 30} = 5.

Let’s try to use the standard method for computing the GCD between the two numbers. Decomposing them into prime factors we’ll obtain:

10 = 2 \cdot 5
15 = 3 \cdot 5

We can note that the only common factor, which is powered to 1 in both numbers, is 5. So the greatest common divisor is 5, that is the same result we obtained by applying the property.

Exercises

Compute GCD(42, 60) and lcm(42, 60).

GCD(42, 60) = 6
lcm(42, 60) = 420
Compute GCD(150, 225) and lcm(150, 225).

GCD(150, 225) = 75
lcm(150, 225) = 450
Compute GCD(125, 270) and lcm(125, 270).

GCD(125, 270) = 5
lcm(1125, 270) = 6750
Compute GCD(45, 60, 75) and lcm(45, 60, 75).

GCD(45, 60, 75) = 15
lcm(45, 60, 75) = 900
Compute GCD(26, 81, 98) and lcm(26, 81, 98).

GCD(26, 81, 98) = 1
lcm(26, 81, 98) = 103194

How did Mathematics help cicadas evolution?

The magicicada lives most of its life underground in the form of nymph, but, after some time, it emerges for mating and lay down the eggs. Among the 7 species of magicicada discovered so far, 4 remain underground for 13 years, while the other ones remain underground for 17 years.

Every how many years would two populations of magicicada of different species compete for resources and survival during the mating period? The answer is indeed lcm(13, 17) = 13 \cdot 17 = 221, i.e. they would meet every 221 years!

Finally, we can note that both 13 and 17 are prime numbers, which by definition are divisible only by 1 or by themselves. In particular they have no common factor: this is why their least common multiple coincides with their product.

You may also like...