Documentation/Calc Functions/LCM/en

Function name:
LCM

Category:
Mathematical

Summary:
Calculates the least common multiple (LCM) of a set of positive integers. The least common multiple is the smallest positive integer that is a multiple of all the given integer values.

Syntax:
LCM(Integer 1 [; Integer 2 [; … [; Integer 255]]])

Returns:
Returns a non-negative integer that is the least common multiple of the supplied numbers.

Arguments:
Integer 1, Integer 2, …, Integer 255 give the set of positive integers for which the least common multiple is to be calculated. At least one value must be provided. Each argument may take one of the following forms:


 * A positive integer, or an expression that evaluates to a positive integer.
 * A reference to a single cell containing a positive integer.
 * A simple reference to a cell range containing positive integers (for example, A1:B9).
 * The name of a named range, comprising cells containing positive integers.
 * The name of a database range, comprising cells containing positive integers.
 * An inline array of positive integers (for example, {1, 2, 3, 4}).

Note that although LCM can accept up to 255 arguments, each argument could specify a range of cells. This means that the number of positive integers processed could be many more than 255.

The following conditions (including errors) may be encountered:


 * If any argument is a string in quotation marks, or a reference to a single cell that contains a string rather than a positive integer, then LCM reports a #VALUE! error.
 * Text and empty cells within a data range are ignored.
 * If any value is negative, then LCM reports an invalid argument error (Err:502).
 * If any value is not an integer, that value is truncated to its floor value.
 * If after any truncation all supplied values are equal to 0, then LCM returns the value 0.

Additional details:

 * LCM ignores any text or empty cells within a data range. If you suspect wrong results, look for text within the supplied data range(s). To highlight text content within a data range, use Calc's feature.

$$i\times j~=~\text {LCM}(i, j) \times \text{GCD}(i, j)$$
 * For two positive integers i and j, the following relationship holds:
 * GCD(i, j) is the greatest common divisor of i and j (see GCD).


 * The least common multiple (LCM) is sometimes referred to as the lowest common multiple or the smallest common multiple.


 * For more background information, visit Wikipedia’s Least common multiple page.

Related LibreOffice functions:
GCD

LCM_EXCEL2003

ODF standard:
Section 6.16.38, part 2

Equivalent Excel functions:
LCM