The function GCD returns the greatest common divisor of one or more Numbers.

Declaration

GCD(first_number, second_number, nth_number, ...) -> greatest_common_divisor

Parameters

first_number, second_number, nth_number (type: at least one number)
The numbers to compute the greatest common divisor for.

Return Values

greatest_common_divisor (type: number)
The greatest common divisor

Examples

The numbers six, nine, and fifteen are all divisible by the number three.

GCD(6, 9, 15) -> 3

The numbers five, ten, and fifteen are all divisible by the number five.

GCD(5, 10, 15) -> 5

While the numbers fifteen, thirty, and forty-five are all divisible by both three and five, the largest divisor is fifteen.

GCD(15, 30, 45) -> 15
Between the numbers two, three, and four, the largest common divisor is one, as any number is divisible by one.
GCD(2, 3, 4) -> 1

The greatest common divisor of the number fifteen is fifteen, as any number is divisible by itself.

GCD(15) -> 15

Was this article helpful?

0 out of 0 found this helpful

Articles in this section