LCM
Returns the least common multiple of one or two integers.
LCM truncates fractional arguments toward zero and combines values iteratively.
The Formualizer engine in this repository at 0.15.0 plus unreleased changes computes the example results. Known differences from Excel are listed on this page.
Syntax
=LCM(number1, [number2])
Arguments
| Argument | Type | Required | Default |
|---|---|---|---|
number1 | number | Required | — |
number2 | number | Optional | — |
Differences from Excel
Formualizer accepts at most two arguments. Excel accepts up to 255.
Remarks
- Inputs must be non-negative and within the supported Excel-compatible range.
- If any input is
0, the resulting least common multiple is0. - Any argument error propagates immediately.
Examples
Compute the result for two positive integers with common factors.
Formula =LCM(18,24)
Expected result 72
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Use fractional inputs to see the effect of truncation.
Formula =LCM(18.7,24.2)
Expected result 72
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Include a zero as one of the operands.
Formula =LCM(0,24)
Expected result 0
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
A negative operand falls outside the supported domain.
Formula =LCM(-18,24)
Expected result #NUM!
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Least common multiple for two integers
Formula =LCM(4, 6)
Expected result 12
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Fractional values are truncated
Formula =LCM(6.8, 8.2)
Expected result 24
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Negative values return numeric error
Formula =LCM(-3, 6)
Expected result #NUM!
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Related functions
FAQ
Why does LCM return 0 when one argument is 0?
LCM is defined as 0 if any truncated input is 0 in this implementation.
Are fractional inputs accepted?
Yes, but they are truncated toward zero before the LCM calculation.