Excel function

GCDfunction

Returns the greatest common divisor of two integers. Decimals use only the integer part.

All versions
=GCD(A2, 12)
A
B
1
2
3
4
5
6
7

Click a cell in the table to change number. Click 15 and set number2 to 25. The greatest common divisor is 5. Try breaking it on purpose to see the errors.

Result

3

number
A2You can also click a cell in the table

The cell with the number to calculate. Click another value in the table.

number2

The other integer. In Excel you can give up to 255 numbers.

What is the GCD function?

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

GCD returns the greatest common divisor: the largest integer that divides all the numbers evenly.

According to Microsoft, decimals are truncated, and any value below 0 returns #NUM!.

GCD reduces fractions, finds a screen's aspect ratio (1920 × 1080 is 16:9) and gives the largest square tile that covers a floor with no cutting: anywhere you need the biggest number that divides everything evenly.

Arguments

number1, number2, ...
From 1 to 255 integers.

GCD examples

  1. Example 1. 5 and 2

    =GCD(5, 2)

    An example from Microsoft: 1.

  2. Example 2. 24 and 36

    =GCD(24, 36)

    12.

  3. Example 3. Three numbers

    =GCD(24, 36, 60)

    12. You can give up to 255 arguments.

  4. Example 4. Ratios and reduced fractions

    =A2/GCD(A2,B2)&":"&B2/GCD(A2,B2)

    Dividing both numbers by their greatest common divisor gives the simplest ratio.

    A2B2GCDResult
    1920108012016:9
    121862:3
    3602401203:2
  5. Example 5. Largest square tile

    =GCD(360, 240)

    A 360 cm × 240 cm floor is covered exactly by 120 cm tiles, 3 by 2.

Common mistakes

FAQ

How do I simplify a fraction?
Divide the numerator and denominator by their GCD.
Can I use a range?
Yes, for example =GCD(A2:A10).
And the least common multiple?
Use LCM. For two numbers, GCD × LCM equals their product.