IMath.Gcd

Syntax

Gcd(Values: Array): Integer;

Parameters

Values. Integer array.

Description

The Gcd method returns greatest common divisor.

Comments

It is required to use an array of value of the Integer type.

The function works correctly with both one-dimension and two-dimension arrays.

To get the least common multiple, use the IMath.Lcm method.

Example

To execute the example, add a link to the MathFin system assembly.

Sub UserProc;
Var r: Double;
    arr: Array[5Of Integer;
Begin
    arr[0] := 24;
    arr[1] := 64;
    arr[2] := 32;
    arr[3] := 8;
    arr[4] := 16;
    r:= math.Gcd(arr);
    Debug.WriteLine(r);
End Sub UserProc;

After executing the example the console window displays the greatest common divisor equal to 8.

See also:

IMath