- number1 - The first number.
- number2 - [optional] The second number.
The GCD function returns the greatest common divisor of two or more integers. The greatest common divisor is the largest positive integer that divides the numbers without a remainder. In other words, the largest number that goes into all numbers evenly.
The GCD function takes one or more arguments called number1, number2, number3, etc. All numeric values are expected to be integers. Numbers with decimal values will be truncated to integers before a result is calculated. Each argument can be a hardcoded constant, a cell reference, or a range that contains multiple values. The GCD function can accept up to 255 arguments total.
To return the greatest common divisor of the numbers 60 and 36:
=GCD(60,36) // returns 12
GCD returns the number 12, since 12 is the largest factor that goes into both numbers evenly. To get the greatest common divisor of 12, 16, 48:
=GCD(12,16,48) // returns 4
In the example workbook shown above, the formula in F5 is:
As the formula is copied down, the GCD function returns a new result for each row, based on the values in columns B, C, and D. Empty cells are evaluated as zero.
- GCD evaluates empty cells as zero.
- GCD works with integers; decimal values are removed before calculation.
- If arguments contain a non-numeric value. GCD returns the #VALUE! error.
- To calculate the least common multiple, see the LCM function.