GCD
Find the greatest common divisor of two or more integers with Excel's GCD function
Spreadsheet editor
Spreadsheet editor
Syntax
=GCD(Number1, Number2, ...)
Returns: Number Arguments
| Argument | Required | Description |
|---|---|---|
| Number1 | Yes | The first number or list of numbers for which you want to find the greatest common divisor. |
| Number2 | Yes | The second number, or subsequent numbers, for which you want to find the greatest common divisor. |
About
This function comes in handy when working with ratios, scaling measurements, or dividing quantities into equal parts. For example, if you're splitting resources evenly across teams or reducing recipe proportions while maintaining the same ratios, GCD helps you find the largest unit that works for all values. For finding the smallest common multiple instead, check out LCM.
GCD accepts up to 255 numbers and automatically truncates decimals to integers. If you need to check remainders after division, try MOD.
Examples
GCD with zero values
Spreadsheet editor
Decimal truncation pitfall
Spreadsheet editor
Combining GCD with ABS for negative values
Spreadsheet editor
Watch out for
Negative numbers return errors
GCD returns a #NUM! error if any number is negative, even though mathematically the greatest common divisor exists for negative integers.
→ Wrap negative values with the ABS function to convert them to positive numbers: =GCD(ABS(-24), ABS(-36)).
Decimal values get truncated
GCD automatically removes decimal portions without rounding. Using GCD(5.9, 3.9) treats the values as 5 and 3, which might not be what you expect.
→ If you need to preserve decimal precision, multiply your numbers by a power of 10 first, find the GCD, then divide the result by the same amount.
Large numbers cause errors
Numbers larger than 2^53 (about 9 quadrillion) return a #NUM! error because Excel can't process them accurately.
→ Keep your values below this limit. For most practical applications like measurements and counting, this limit is rarely an issue.