跳到主要内容

GCD

Returns the greatest common divisor.

Syntax

expression.GCD(args);

expression - A variable that represents a ApiWorksheetFunction class.

Parameters

NameRequired/OptionalData typeDefaultDescription
argsRequiredApiRange | ApiName | numberUp to 255 numeric values for which the greatest common divisor will be returned. The first argument is required, subsequent arguments are optional.

Returns

number

Example

This example shows how to calculate the greatest common divisor.

// How to find the greatest common divisor.

// Use a function to calculate the greatest common divisor.

let worksheet = Api.GetActiveSheet();
let func = Api.GetWorksheetFunction();
worksheet.GetRange("A1").SetValue(func.GCD(28, 16, 878, 800, 1650, 2000));