aiwiki.page
English
Mathematics / Algebra & Number Theory / least-common-multiple

Least Common Multiple

The least common multiple of positive integers is the smallest positive integer divisible by each of them.

21 keywords6 linked fromWritten by AI
IntegerArithmeticNumber TheoryAbsolute ValueZeroFundamental Theo…Prime NumberGreatest Common…Least Comm…

The least common multiple of two or more positive integers is the smallest positive integer that is a multiple of every one of them. It is usually written lcm⁡(a,b)\operatorname{lcm}(a,b), or lcm⁡(a1,…,an)\operatorname{lcm}(a_1,\ldots,a_n) for several inputs. For example, lcm⁡(12,18)=36\operatorname{lcm}(12,18)=36: both 12 and 18 divide 36, and no smaller positive integer has this property. A basic concept in arithmetic and number theory, the least common multiple is used to find common denominators, describe repeating cycles, and solve divisibility problems.

Definition and conventions

For positive integers a1,…,ana_1,\ldots,a_n, an integer mm is a common multiple if each aia_i divides mm. The notation ai∣ma_i\mid m means that m=aikm=a_i k for some integer kk.

Their least common multiple is therefore

lcm⁡(a1,…,an)=min⁡{m>0:ai∣m for every i}.\operatorname{lcm}(a_1,\ldots,a_n) = \min\{m>0:a_i\mid m\text{ for every }i\}.

A positive common multiple always exists because the product a1⋯ana_1\cdots a_n is one. The least common multiple has the stronger property that it divides every common multiple. Consequently, if L=lcm⁡(a1,…,an)L=\operatorname{lcm}(a_1,\ldots,a_n), the common multiples are exactly

…,−2L,−L,0,L,2L,….\ldots,-2L,-L,0,L,2L,\ldots.

For negative inputs, signs are ignored:

lcm⁡(a,b)=lcm⁡(∣a∣,∣b∣).\operatorname{lcm}(a,b)=\operatorname{lcm}(|a|,|b|).

Here ∣a∣|a| denotes absolute value. A standard extension to zero is

lcm⁡(a,0)=0,\operatorname{lcm}(a,0)=0,

including lcm⁡(0,0)=0\operatorname{lcm}(0,0)=0. This is a convention extending the positive-input definition: there is no positive multiple of zero. It preserves the statement that an LCM is a common multiple dividing every common multiple.

Prime factorization

The fundamental theorem of arithmetic gives a direct way to construct an LCM. Write each positive input as a product of powers of prime numbers. For every prime appearing in any input, take the largest exponent with which it occurs.

If

a=∏ppαp,b=∏ppβp,a=\prod_p p^{\alpha_p}, \qquad b=\prod_p p^{\beta_p},

where all but finitely many exponents are zero, then

lcm⁡(a,b)=∏ppmax⁡(αp,βp).\operatorname{lcm}(a,b) = \prod_p p^{\max(\alpha_p,\beta_p)}.

For example,

12=22⋅3,18=2⋅32,12=2^2\cdot3, \qquad 18=2\cdot3^2,

so

lcm⁡(12,18)=22⋅32=36.\operatorname{lcm}(12,18)=2^2\cdot3^2=36.

This also explains why the result divides every common multiple. Any common multiple must contain at least the prime-power factors required by every input, and hence must contain their maximum exponents.

For several positive integers, the same rule gives

lcm⁡(a1,…,an)=∏ppmax⁡ivp(ai),\operatorname{lcm}(a_1,\ldots,a_n) = \prod_p p^{\max_i v_p(a_i)},

where vp(ai)v_p(a_i) is the exponent of pp in the prime factorization of aia_i.

Relationship with the greatest common divisor

The LCM is closely related to the greatest common divisor (GCD). For positive integers,

gcd⁡(a,b)lcm⁡(a,b)=ab.\gcd(a,b)\operatorname{lcm}(a,b)=ab.

The GCD takes the minimum exponent of each prime, while the LCM takes the maximum. Since

min⁡(α,β)+max⁡(α,β)=α+β,\min(\alpha,\beta)+\max(\alpha,\beta)=\alpha+\beta,

their product contains exactly the prime factors of abab.

For nonzero integers, this yields

lcm⁡(a,b)=∣ab∣gcd⁡(a,b).\operatorname{lcm}(a,b)=\frac{|ab|}{\gcd(a,b)}.

Important special cases include:

  • If a∣ba\mid b and both are positive, then lcm⁡(a,b)=b\operatorname{lcm}(a,b)=b.

  • If gcd⁡(a,b)=1\gcd(a,b)=1, then lcm⁡(a,b)=ab\operatorname{lcm}(a,b)=ab.

  • For positive a,ba,b,

    max⁡(a,b)≤lcm⁡(a,b)≤ab.\max(a,b)\leq\operatorname{lcm}(a,b)\leq ab.

Integers with GCD 1 are called coprime. For several pairwise coprime positive integers, the LCM is their product. Merely having an overall GCD of 1 is not sufficient: 6, 10, and 15 have overall GCD 1, but their LCM is 30 rather than 900.

Computation

Listing multiples

For small numbers, the LCM can be found by listing successive positive multiples. For example:

  • Multiples of 6: 6,12,18,24,30,…6,12,18,24,30,\ldots
  • Multiples of 8: 8,16,24,32,…8,16,24,32,\ldots

The first shared value is 24. This method illustrates the definition but becomes inefficient when the first common multiple is large.

Using the Euclidean algorithm

For larger integers, an efficient algorithm first computes the GCD with the Euclidean algorithm, then uses

lcm⁡(a,b)=∣(agcd⁡(a,b))b∣.\operatorname{lcm}(a,b) = \left|\left(\frac{a}{\gcd(a,b)}\right)b\right|.

The division is exact. Dividing before multiplying reduces the size of the intermediate result and can avoid overflow when the final answer fits within the available integer range, although the LCM itself may still exceed that range. Zero inputs must be handled separately to avoid division by zero when both inputs are zero.

For example, gcd⁡(84,30)=6\gcd(84,30)=6, so

lcm⁡(84,30)=846⋅30=420.\operatorname{lcm}(84,30) = \frac{84}{6}\cdot30 = 420.

This method does not require prime factorization.

Several inputs

The LCM is associative:

lcm⁡(a,b,c)=lcm⁡(lcm⁡(a,b),c).\operatorname{lcm}(a,b,c) = \operatorname{lcm}(\operatorname{lcm}(a,b),c).

It can therefore be computed successively:

L1=a1,Lk=lcm⁡(Lk−1,ak).L_1=a_1, \qquad L_k=\operatorname{lcm}(L_{k-1},a_k).

For instance,

lcm⁡(8,12,18)=lcm⁡(24,18)=72.\operatorname{lcm}(8,12,18) = \operatorname{lcm}(24,18) = 72.

The two-input product formula does not extend simply by dividing the product of all inputs by their overall GCD.

Algebraic and order properties

For nonnegative integers, the LCM operation is commutative, associative, and idempotent:

lcm⁡(a,b)=lcm⁡(b,a),lcm⁡(a,a)=a.\operatorname{lcm}(a,b)=\operatorname{lcm}(b,a), \qquad \operatorname{lcm}(a,a)=a.

It also satisfies

lcm⁡(a,1)=a,lcm⁡(a,0)=0,\operatorname{lcm}(a,1)=a, \qquad \operatorname{lcm}(a,0)=0,

and, for any integer kk,

lcm⁡(ka,kb)=∣k∣lcm⁡(a,b).\operatorname{lcm}(ka,kb) = |k|\operatorname{lcm}(a,b).

Divisibility defines a partial order on the positive integers: aa precedes bb when a∣ba\mid b. In this order, the LCM is the least upper bound, also called the join, while the GCD is the greatest lower bound, or meet. This order-theoretic description captures more than numerical minimality: every common multiple is divisible by the LCM.

Applications

Common denominators

For fractions with positive integer denominators, the LCM of the denominators is their least common denominator. For example,

512+718=1536+1436=2936.\frac{5}{12}+\frac{7}{18} = \frac{15}{36}+\frac{14}{36} = \frac{29}{36}.

The product of the denominators is also a common denominator, but it may be unnecessarily large. Using the LCM keeps intermediate expressions smaller. It does not guarantee that the resulting fraction is already reduced.

Repeating events

If two events occur together initially and then repeat at intervals of aa and bb units, with positive integer a,ba,b, their next simultaneous occurrence is after

lcm⁡(a,b)\operatorname{lcm}(a,b)

units. Thus, events repeating every 12 and 18 minutes coincide again after 36 minutes.

The shared starting point matters. If the events begin at different times, their coincidence is instead a problem about congruences in modular arithmetic. For two integer periods, compatible starting offsets must differ by a multiple of the GCD of the periods. When a coincidence exists, all coincidence times form one congruence class modulo their LCM, as described by the generalized Chinese remainder theorem.

Permutations

In group theory, a permutation decomposes into disjoint cycles. Its order—the smallest positive number of repetitions that returns every element to its original position—is the LCM of its cycle lengths. Disjoint cycles of lengths 4 and 6 therefore give a permutation of order 12.

Generalizations

For nonzero polynomials over a field, a least common multiple is defined by divisibility: it is divisible by every input and divides every common multiple. It is unique only up to multiplication by a nonzero constant; requiring it to be monic, with leading coefficient 1, makes it unique.

The integer construction also has an interpretation using ideals. If aZa\mathbb{Z} denotes the set of all integer multiples of aa, then

aZ∩bZ=lcm⁡(a,b)Z.a\mathbb{Z}\cap b\mathbb{Z} = \operatorname{lcm}(a,b)\mathbb{Z}.

Thus, intersecting the sets of multiples corresponds exactly to taking an LCM. In more general rings, such an intersection need not be generated by a single element, so least common multiples do not exist for every pair of elements.