Exceljet

Quick, clean, and to the point

Excel GCD Function

Excel GCD function
Summary 

The Excel GCD function returns the greatest common divisor of two or more integers. The greatest common divisor is the largest integer that goes into all supplied numbers without a remainder. For example, =GCD(60,36) returns 12.

Purpose 
Get the greatest common divisor of numbers
Return value 
The largest positive integer that divides the numbers evenly
Syntax 
=GCD (number1, [number2], ...)
Arguments 
  • number1 - The first number.
  • number2 - [optional] The second number.
Version 
Usage notes 

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.

Examples

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:

=GCD(B5:D5)

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.

Notes

  • 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.

Download 100+ Important Excel Functions

Get over 100 Excel Functions you should know in one handy PDF.