Skip to main content

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

Calculate the greatest common divisor in a spreadsheet.

// How to find the greatest common divisor in a spreadsheet.

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

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