UNPKG

943 BMarkdownView Raw
1<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
2
3# Function lcm
4
5Calculate the least common multiple for two or more values or arrays.
6
7lcm is defined as:
8
9 lcm(a, b) = abs(a * b) / gcd(a, b)
10
11For matrices, the function is evaluated element wise.
12
13
14## Syntax
15
16```js
17math.lcm(a, b)
18math.lcm(a, b, c, ...)
19```
20
21### Parameters
22
23Parameter | Type | Description
24--------- | ---- | -----------
25`args` | ... number &#124; BigNumber &#124; Array &#124; Matrix | Two or more integer numbers
26
27### Returns
28
29Type | Description
30---- | -----------
31number &#124; BigNumber &#124; Array &#124; Matrix | The least common multiple
32
33
34## Examples
35
36```js
37math.lcm(4, 6) // returns 12
38math.lcm(6, 21) // returns 42
39math.lcm(6, 21, 5) // returns 210
40
41math.lcm([4, 6], [6, 21]) // returns [12, 42]
42```
43
44
45## See also
46
47[gcd](gcd.md),
48[xgcd](xgcd.md)