跳到主要内容

LCM

返回最小公倍数。

语法

expression.LCM(args);

expression - 表示 ApiWorksheetFunction 类的变量。

参数

名称必需/可选数据类型默认值描述
args必需ApiRange | ApiName | number最多 255 个将返回最小公倍数的数值。第一个参数是必需的,后续参数是可选的。

返回值

number

示例

此示例演示如何返回最小公倍数。

// How to find the least common multiple from the list of numbers.

// Use a function to find out the least common multiple.

let worksheet = Api.GetActiveSheet();
let func = Api.WorksheetFunction;
worksheet.GetRange("A1").SetValue(func.LCM(4, 6, 8, 8, 12, 24, 2, 1));