Practice free

GCD function

GCD returns the greatest common divisor, the largest whole number that divides all your inputs evenly. It is useful for simplifying ratios and fractions, and decimals are truncated first.

Example

Read it as a sentence: find the largest number that divides evenly into 24, 36 and 60, which gives 12.

Practice this in the app

Syntax

GCD(number1, [number2], ...)

Arguments in [square brackets] are optional.

number1 (required)
The first whole number.
[number2], ... (optional)
More whole numbers, up to 255.

Returns: The largest whole number that divides all the inputs evenly.

What Excel actually returns

Each formula below was run in desktop Excel. The result is exactly what the cell showed, errors included.

FormulaExcel showsCase
=GCD(12,18) 6 12,18
=GCD(7) 7 Single 7
=GCD(0,5) 5 With 0
=GCD(0,0) 0 All zero
=GCD(12.9,18.2) 6 Non-integer truncates
=GCD({4,6,8}) 2 Array constant
=GCD(-4,6) #NUM! Negative
=GCD("a",18) #VALUE! Text arg

Watch out for

  • Decimals are truncated.
  • Negatives return #NUM!.

Where it works

Excel
GCD is in every version of Excel from 2007 on.
Google Sheets
Same name, same behaviour for everyday use.

Part of Math and trig functions. Every result on this page was measured in desktop Excel, build 16.0.20527. Last updated .