Function lcm

Calculate the least common multiple for two or more values or arrays.

lcm is defined as:

lcm(a, b) = abs(a * b) / gcd(a, b)

For matrices, the function is evaluated element wise.

Syntax

lcm(a, b)
lcm(a, b, c, ...)

Parameters

Parameter Type Description
args ... number | BigNumber | Array | Matrix Two or more integer numbers

Returns

Type Description
number | BigNumber | Array | Matrix The least common multiple

Examples

lcm(4, 6);               // returns 12
lcm(6, 21);              // returns 42
lcm(6, 21, 5);           // returns 210

lcm([4, 6], [6, 21]);    // returns [12, 42]

See also

gcd, xgcd