# Documentation/Calc Functions/GCD

From The Document Foundation Wiki

TDF LibreOffice Document Liberation Project Community Blogs Weblate Nextcloud Redmine Ask LibreOffice Donate

## Function name:

GCD

## Category:

Mathematical

## Summary:

The function gives the greatest common divisor of two or more positive integers.

The greatest common divisor is the positive largest integer which will divide, without remainder, each of the given positive integers.

## Syntax:

GCD(**Integer 1** [; **Integer 2** [; … [; **Integer 255**]]])

## Returns:

Returns an integer which is the greatest common divisor of two or more positive integers passed as input.

## Arguments:

**Integer 1**, **Integer 2**, … , **Integer 255** are integers, references to cells or to cell ranges of integers whose greatest common divisor is to be calculated.

- If any argument is negative, the function returns an error value.
- If any argument is non-integer, the function returns an integer GCD value. For e.g. GCD(2.5;5) will return 1 while GCD(8;2.2) will return 2.

## Additional details:

If given two positive integers, a*b=LCM(a;b)*GCD(a;b).

## Examples:

Formula | Description | Returns |
---|---|---|

=GCD(16;32;24) | the largest number that can divide 16, 24 and 32 without a remainder | 8 |

=GCD(B1:B3) ,where cells B1, B2, B3 contain 9, 12, 9 | the largest number that can divide 9, 12 and 9 without a remainder | 3 |

=GCD(-16;32;24) | function returns an error value since one of the arguments is negative | Err:502 |

## Related LibreOffice functions:

## ODF standard:

## Equivalent Excel functions:

GCD