In arithmetic and number theory, the least common multiple
(also called the lowest common multiple
or smallest common multiple
) of two integers a
, usually denoted by LCM(a, b)
, is the smallest positive integer that is divisible by both a
. If either a
is 0, LCM(a
) is defined to be zero.
The LCM is familiar from grade-school arithmetic as the "least common denominator" (LCD) that must be determined before fractions can be added, subtracted or compared.
The LCM of more than two integers is also well-defined: it is the smallest integer that is divisible by each of them.
A multiple of a number is the product of that number and an integer. For example, 10 is a multiple of 5 because 5 × 2 = 10, so 10 is divisible by 5 and 2. Because 10 is the smallest positive integer that is divisible by both 5 and 2, it is the least common multiple of 5 and 2. By the same principle, 10 is the least common multiple of −5 and 2 as well.
In this article we will denote the least common multiple of two integers a
as lcm( a
). Some older textbooks use [ a
What is the LCM of 4 and 6?
Multiples of 4 are:
and the multiples of 6 are:
of 4 and 6 are simply the numbers that are in both lists:
So, from this list of the first few common multiples of the numbers 4 and 6, their least common multiple
When adding, subtracting, or comparing vulgar fractions, it is useful to find the least common multiple of the denominators, often called the lowest common denominator, because each of the fractions can be expressed as a fraction with this denominator. For instance,
where the denominator 42 was used because it is the least common multiple of 21 and 6.
Many school age children are taught the term greatest common factor (GCF) instead of the greatest common divisor(GCD); therefore, for those familiar with the concept of GCF, substitute GCF when GCD is used below.
The following formula reduces the problem of computing the least common multiple to the problem of computing the greatest common divisor (GCD):
This formula is also valid when exactly one of a
is 0, since gcd(a
, 0) = |a
There are fast algorithms for computing the GCD that do not require the numbers to be factored, such as the Euclidean algorithm. To return to the example above,
) is a divisor of both a
, it's more efficient to compute the LCM by dividing before
This reduces the size of one input for both the division and the multiplication, and reduces the required storage needed for intermediate results (overflow in the a
computation). Because gcd(a
) is a divisor of both a
, the division is guaranteed to yield an integer, so the intermediate result can be stored in an integer. Done this way, the previous example becomes:
The unique factorization theorem says that every positive integer greater than 1 can be written in only one way as a product of prime numbers. The prime numbers can be considered as the atomic elements which, when combined together, make up a composite number.
Here we have the composite number 90 made up of one atom of the prime number 2, two atoms of the prime number 3 and one atom of the prime number 5.
This knowledge can be used to find the LCM of a set of numbers.
Example: Find the value of lcm(8,9,21).
First, factor out each number and express it as a product of prime number powers.
The lcm will be the product of multiplying the highest power of each prime number together. The highest power of the three prime numbers 2, 3, and 7 is 23, 32, and 71, respectively. Thus,
This method is not as efficient as reducing to the greatest common divisor, since there is no known general efficient algorithm for integer factorization, but is useful for illustrating concepts.
This method can be illustrated using a Venn diagram as follows. Find the prime factorization of each of the two numbers. Put the prime factors into a Venn diagram with one circle for each of the two numbers, and all
factors they share in common in the intersection. To find the LCM, just multiply all of the prime numbers in the diagram.
Here is an example:
and what they share in common is two "2"s and a "3":
This also works for the greatest common divisor (GCD), except that instead of multiplying all of the numbers in the Venn diagram, one multiplies only the prime factors that are in the intersection. Thus the GCD of 48 and 180 is 2 × 2 × 3 = 12.
This method works as easily for finding the LCM of several integers.
Let there be a finite sequence of positive integers X
, ..., xn
> 1. The algorithm proceeds in steps as follows: on each step m
it examines and updates the sequence X
( = (x1
(, ..., xn
(1) = X
, where X
( is the m
th iteration of X
, i.e. X
at step m
of the algorithm, etc. The purpose of the examination is to pick up the least (perhaps, one of many) element of the sequence X
(. Assuming xk0
( is the selected element, the sequence X
( is defined as
In other words, the least element is increased by the corresponding x
whereas the rest of the elements pass from X
( to X
The algorithm stops when all elements in sequence X
( are equal. Their common value L
is exactly LCM(X
). (For a proof and an interactive simulation see reference below, Algorithm for Computing the LCM
This method works for any number of factors. One begins by listing all of the numbers vertically in a table (in this example 4, 7, 12, 21, and 42):
The process begins by dividing all of the factors by 2. If any of them divides evenly, write 2 at the top of the table and the result of division by 2 of each factor in the space to the right of each factor and below the 2. If a number does not divide evenly, just rewrite the number again. If 2 does not divide evenly into any of the numbers, try 3.
Now, check if 2 divides again:
Once 2 no longer divides, divide by 3. If 3 no longer divides, try 5 and 7. Keep going until all of the numbers have been reduced to 1.
Now, multiply the numbers on the top and you have the LCM. In this case, it is 2 × 2 × 3 × 7 = 84. You will get to the LCM the quickest if you use prime numbers and start from the lowest prime, 2.
According to the fundamental theorem of arithmetic a positive integer is the product of prime numbers, and, except for their order, this representation is unique:
where the exponents n2
, ... are non-negative integers; for example, 84 = 22 31 50 71 110 130 ...
Given two integers
their least common multiple and greatest common divisor are given by the formulas
In fact, any rational number can be written uniquely as the product of primes if negative exponents are allowed. When this is done, the above formulas remain valid. Using the same examples as above:
The positive integers may be partially ordered by divisibility: if a
(i.e. if b
is an integer multiple of a
) write a
(or equivalently, b
). (Forget the usual magnitude-based definition of ≤ in this section - it isn't used.)
Under this ordering, the positive integers become a lattice with meet given by the gcd and join given by the lcm. The proof is straightforward, if a bit tedious; it amounts to checking that lcm and gcd satisfy the axioms for meet and join. Putting the lcm and gcd into this more general context establishes a duality between them:
The following pairs of dual formulas are special cases of general lattice-theoretic identities.
It can also be shown that this lattice is distributive, i.e. that lcm distributes over gcd and, dually, that gcd distributes over lcm:
This identity is self-dual:
be the product of ω(D
) distinct prime numbers (i.e. D
where the absolute bars || denote the cardinality of a set.
The least common multiple can be defined generally over commutative rings as follows: Let a
be elements of a commutative ring R
. A common multiple of a
is an element m
such that both a
(i.e. there exist elements x
such that ax
). A least common multiple of a
is a common multiple that is minimal in the sense that for any other common multiple n
In general, two elements in a commutative ring can have no least common multiple or more than one. However, any two least common multiples of the same pair of elements are associates. In a unique factorization domain, any two elements have a least common multiple. In a principal ideal domain, the least common multiple of a
can be characterised as a generator of the intersection of the ideals generated by a
(the intersection of a collection of ideals is always an ideal). In principal ideal domains, one can even talk about the least common multiple of arbitrary collections of elements: it is a generator of the intersection of the ideals generated by the elements of the collection.