LCM[n1,n2,…]
gives the least common multiple of the ni.
LCM
LCM[n1,n2,…]
gives the least common multiple of the ni.
Details
- LCM is also known as smallest common multiple.
- Integer mathematical function, suitable for both symbolic and numerical manipulation.
- LCM[n1,n2,…] is the smallest positive integer that is a multiple of each of the integers n1,n2,….
- For rational numbers ri, LCM[r1,r2,…] gives the least rational number r for which all the r/ri are integers.
- LCM works over Gaussian integers.
Examples
open all close allBasic Examples (2)
Scope (11)
Numerical Evaluation (7)
LCM works over integers:
LCM[3, -5, 7]LCM[-4 + 5I, 2 + 3I]LCM[1 / 3, 2 / 5, 3 / 7]LCM[1 / 2 + 3 / 5I, 1 / 3 + I]The one-argument form is identity for positive integers:
LCM[5]LCM[20!, 10 ^ 100 + 3]LCM threads elementwise over lists:
LCM[12, {3, 7, 40}]Symbolic Manipulation (4)
TraditionalForm formatting:
TraditionalForm[LCM[n, m]]Reduce[LCM[a, 3] < 3a && -10 < a < 10, a, Integers]Solve[LCM[m, n] == n ^ 2 + n && 1 < n < 10 && 1 < m < 10, {m, n}, Integers]FullSimplify[LCM[p, q], {p, q}∈Primes && p ≠ q]FullSimplify[LCM[m, n]GCD[m, n], {m, n}∈Integers]Applications (9)
Basic Applications (4)
Table of the LCMs of the first 100 pairs of integers:
Grid[Table[If[i * j == 0, If[i + j == 0, "", Style[i + j, Red, Italic, Bold]], LCM[i, j]], {i, 0, 10}, {j, 0, 10}], ...]Visualize the LCMs of two integers:
ArrayPlot[Table[LCM[m, n], {m, 50}, {n, 50}]]ArrayPlot[Mod[Table[LCM[Fibonacci[j], Fibonacci[k]], {j, 100}, {k, 100}], Fibonacci[11]]]The LCM of the first 100 integers:
Apply[LCM, Range[100]]Compute LCM for positive integers:
lcm[a0_, b0_] := Module[{a = a0, b = b0}, While[b ≠ 0, {a, b} = {b, Mod[a, b]};];a0 * b0 / a];lcm[10, 15]LCM[10, 15]Number Theory (5)
FoldList[LCM, 1, Range[2, 10]]Plot the logarithm of the data (if Riemann's hypothesis holds, this grows linearly):
ListPlot[Log[FoldList[LCM, 1, Range[2, 100]]]]The sum of MangoldtLambda of the first n integers is equal to the natural log of the LCM of the first n integers:
Sum[MangoldtLambda[n], {n, 10}]//SimplifyLog[Apply[LCM, Range[10]]]Maximal order of group elements from the symmetric group of order n (Landau's function):
Table[Max[LCM@@@IntegerPartitions[n]], {n, 20}]LCMs of binomial coefficients:
Table[LCM@@Binomial[n, Range[0, n]], {n, 0, 12}]Table[1 / n LCM@@Range[1, n], {n, 13}]Simplify expressions containing LCM:
FullSimplify[LCM[p, q], {p, q}∈Primes && p ≠ q]FullSimplify[LCM[m, n]GCD[m, n], {m, n}∈Integers]FullSimplify[LCM[LCM[l, m], n], {l, m, n}∈Integers]Properties & Relations (7)
Every divisor of a and b is a divisor of
:
AllTrue[Union[Divisors[24], Divisors[70]], Divisible[840, #]&]27 81 / GCD[27, 81]LCM[27, 81]The LCM of coprime numbers is equal to their product:
CoprimeQ[6, 11, 25]LCM[6, 11, 25] == 6 11 25LCM for prime numbers is their product:
PrimeQ[{5, 7, 2}]LCM[5, 7, 2] == 5 7 2LCM for prime power representation
:
nvec = {1, 2, 3, 4, 5};
mvec = {5, 4, 3, 2, 1};LCM[Subsuperscript[∏, i = 1, 5]Prime[i]^nvec[[i]], Subsuperscript[∏, i = 1, 5]Prime[i]^mvec[[i]]] == Subsuperscript[∏, i = 1, 5]Prime[i]^Max[nvec[[i]], mvec[[i]]]LCM is commutative
:
FullSimplify[LCM[a, b] == LCM[b, a], {a, b}∈Integers]LCM is associative
:
FullSimplify[LCM[a, LCM[b, c]] == LCM[LCM[a, b], c], {a, b, c}∈Integers]LCM is distributive
:
FullSimplify[m LCM[a, b] == LCM[m a, m b], {a, b, m}∈Integers && m > 0]Use LCM to compute MangoldtLambda:
Log[LCM@@Range[5] / LCM@@Range[4]]MangoldtLambda[5]Possible Issues (3)
LCM[-3, 7]The arguments must be explicit integers:
LCM[2.4, 5]LCM sorts its arguments:
LCM[b, a]Interactive Examples (1)
Neat Examples (4)
Visualize the LCMs of Fibonacci numbers:
ImageCollage[Table[ArrayPlot[Mod[Table[LCM[Fibonacci[j], Fibonacci[k]], {j, 100}, {k, 100}], Fibonacci[n]]], {n, 5, 30, 5}]]Plot the arguments of the Fourier transform of the LCM:
ArrayPlot[Arg[Fourier[Table[LCM[m, n], {m, 100}, {n, 100}]]], ColorFunction -> Hue]Plot the Ulam spiral of the LCM:
ulam[n_] := Partition[Permute[Range[n ^ 2], Accumulate[Take[Flatten[{{n ^ 2 + 1} / 2, Table
[(-1) ^ j i, {j, n}, {i, {-1, n}}, {j}]}], n ^ 2]]], n]ArrayPlot[LCM[ulam[125], 45], ColorFunction -> "BlueGreenYellow"]Form the LCMs of
with rational numbers:
ListPlot[{#, LCM[1, #]}& /@ Union[Flatten[Table[i / j, {j, 40}, {i, 2j}]]]]Tech Notes
Related Guides
Related Links
History
Introduced in 1988 (1.0) | Updated in 1999 (4.0)
Text
Wolfram Research (1988), LCM, Wolfram Language function, https://reference.wolfram.com/language/ref/LCM.html (updated 1999).
CMS
Wolfram Language. 1988. "LCM." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 1999. https://reference.wolfram.com/language/ref/LCM.html.
APA
Wolfram Language. (1988). LCM. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/LCM.html
BibTeX
@misc{reference.wolfram_2026_lcm, author="Wolfram Research", title="{LCM}", year="1999", howpublished="\url{https://reference.wolfram.com/language/ref/LCM.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_lcm, organization={Wolfram Research}, title={LCM}, year={1999}, url={https://reference.wolfram.com/language/ref/LCM.html}, note=[Accessed: 12-June-2026]}