函数 lcm #

计算两个或多个值或数组的最小公倍数。

lcm 定义为

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

对于矩阵,该函数逐元素求值。

Syntax #

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

Parameters #

Parameter Type Description
args … number | BigNumber | Array | Matrix 两个或多个整数

Returns #

Type Description
number | BigNumber | Array | Matrix 最小公倍数

Throws #

Type | Description —- | ———–

Examples #

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

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

另请参阅 #

gcd, xgcd

Fork me on GitHub