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], ...)| Argument | What it means | |
|---|---|---|
number1 | Required | The first whole number (decimals are truncated). |
number2, ... | Optional | Up 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
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Room | Length (cm) | Width (cm) | |
| 2 | Showroom | 360 | 240 | 120 |
Result: 120
120 cm tiles fit 3 × 2 times with no cutting.
2Simplify a screen ratio
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Screen | Width (px) | Height (px) | |
| 2 | Full HD | 1920 | 1080 | 16:9 |
Result: 16:9
GCD is 120, so 1920/120 = 16 and 1080/120 = 9.
Common errors and how to fix them
| Error | Why it happens | Fix |
|---|---|---|
#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.
| Language | Function name |
|---|---|
| Danish | STØRSTE.FÆLLES.DIVISOR |
| Dutch | GGD |
| Finnish | SUURIN.YHT.TEKIJÄ |
| French | PGCD |
| German | GGT |
| Hungarian | LKO |
| Italian | MCD |
| Norwegian (Bokmål) | SFF |
| Polish | NAJW.WSP.DZIEL |
| Portuguese (Brazil) | MDC |
| Portuguese (Portugal) | MDC |
| Russian | НОД |
| Spanish | M.C.D |
| Swedish | SGD |
| Turkish | OBEB |