Math & trig function

GCD function

Returns the greatest common divisor of two or more integers: the largest number that divides them all.

Available in Excel 2007 and later (earlier with the Analysis ToolPak), Excel for the web, Excel for Mac

Excel 2007 and laterWorks in Google Sheets

Syntax

GCD(number1, [number2], ...)
ArgumentWhat it means
number1RequiredThe first whole number (decimals are truncated).
number2, ...OptionalUp to 255 values or ranges.

Returns: The largest positive integer that divides every value exactly.

How GCD works

GCD finds the biggest number that goes into all your numbers without a remainder. It answers practical layout questions, such as the largest square tile that fits a 360 × 240 cm floor exactly (120 cm), or the largest group size that splits several teams evenly, and it simplifies ratios: 1920:1080 divided by their GCD of 120 is 16:9.

Values must be zero or positive; negative numbers return #NUM!. Decimals are truncated before the calculation, so GCD(12.7, 8) is treated as GCD(12, 8) = 4. If one value is 0, the GCD is the other value. Its partner is LCM, the least common multiple.

Examples

1Largest square tile for a floor

D2fx=GCD(B2, C2)
ABCD
1RoomLength (cm)Width (cm)
2Showroom360240120

Result: 120

120 cm tiles fit 3 × 2 times with no cutting.

2Simplify a screen ratio

D2fx=B2/GCD(B2,C2)&":"&C2/GCD(B2,C2)
ABCD
1ScreenWidth (px)Height (px)
2Full HD1920108016:9

Result: 16:9

GCD is 120, so 1920/120 = 16 and 1080/120 = 9.

⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 13 KB

Common errors and how to fix them

ErrorWhy it happensFix
#NUM!A value is negative.Use ABS() on the inputs.
#VALUE!A non-numeric value.Check the input.

Tips

  • Equal-size groups from several departments: =GCD(B2:B6) gives the largest group size that divides each department exactly.

Google Sheets

GCD also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.

GCD in other languages

In a non-English version of Excel the function has a local name. Excel translates formulas automatically when a file is opened in another language.

LanguageFunction name
DanishSTØRSTE.FÆLLES.DIVISOR
DutchGGD
FinnishSUURIN.YHT.TEKIJÄ
FrenchPGCD
GermanGGT
HungarianLKO
ItalianMCD
Norwegian (Bokmål)SFF
PolishNAJW.WSP.DZIEL
Portuguese (Brazil)MDC
Portuguese (Portugal)MDC
RussianНОД
SpanishM.C.D
SwedishSGD
TurkishOBEB