GCD Function (LibreOffice Calc)
The GCD function in LibreOffice Calc returns the greatest common divisor of one or more integers. It is essential for simplifying ratios, reducing fractions, and solving number theory problems.
Verification status: Consult the documentation, examples and any stated test scope below. How formula examples are checked
Availability and version history
- Introduced: Documented by LibreOffice 26.8.1.1; original introduction not established.
- Availability: Supported in LibreOffice 26.8.1.1, verified against its function registry. This identifies a supported release, not a final working version.
- Scope: Desktop Calc, using the English function name. Availability in other spreadsheet applications is separate.
- Checked: 2026-10-14 — function reference; versioned support. Documentation/source check; not a new native test. Existing example-specific test claims below retain their stated scope.
What the GCD Function Does
- Returns the greatest common divisor of integers
- Accepts multiple arguments or ranges
- Useful for simplifying ratios and fractions
- Works with positive integers
- Complements LCM for integer arithmetic
It is designed to be precise, efficient, and universally compatible.
Syntax
GCD(number1; [number2]; ...)
Arguments
- number1, number2, …
One or more integers or ranges containing integers.
Non-integer values are truncated to integers.
Basic Examples
GCD of two numbers
=GCD(12; 18)
Returns 6.
GCD of multiple numbers
=GCD(12; 18; 24)
Returns 6.
GCD of a range
=GCD(A1:A5)
Computes the GCD of all integers in A1:A5.
GCD with non-integers
=GCD(10.9; 6.2)
Equivalent to GCD(10; 6) → returns 2.
Advanced Examples
Simplify a ratio
=A1 / GCD(A1; B1) & ":" & B1 / GCD(A1; B1)
Converts A1:B1 into simplest form.
Reduce a fraction
=A1 / GCD(A1; B1)
=B1 / GCD(A1; B1)
Returns numerator and denominator in lowest terms.
Check if two numbers are coprime
=GCD(A1; B1) = 1
Returns TRUE if A1 and B1 share no common factors.
GCD with MOD (Euclidean algorithm)
=GCD(A1; B1)
Equivalent to repeatedly applying:
A = MOD(A; B)
GCD for periodic alignment
=GCD(A1; B1)
Useful for finding smallest repeating cycle length.
GCD for scaling integer models
=A1 / GCD(A1:A5)
Normalizes values to smallest integer proportions.
Common Errors and Fixes
GCD returns 0
Occurs when:
- All inputs are 0
- All inputs are empty
- All inputs are text
GCD returns Err:502
Occurs when:
- A range reference is malformed
- A semicolon or colon is misplaced
- A non-numeric argument cannot be coerced
GCD returns unexpected results
Cause:
- Non-integer values are truncated
Example:GCD(10.9; 6.2)→GCD(10; 6)→2.
Best Practices
- Use GCD to simplify ratios and fractions
- Use GCD with LCM for integer arithmetic
- Avoid passing text values
- Use GCD to normalize integer models
- Use GCD to detect coprime numbers
Related Patterns and Alternatives
- Use LCM to compute least common multiples
- Use QUOTIENT for integer division
- Use MOD for remainder-based logic
- Use FACT for factorial-based combinatorics
- Use A1 / GCD(A1:A5) for normalized integer scaling
By mastering GCD and its combinations with other math functions, you can build precise, integer-based models in LibreOffice Calc that handle ratios, divisors, and number theory with clarity and accuracy.
Reproducible example (tested in LibreOffice Calc)
This standalone example was calculated in LibreOffice Calc 25.2.3.2 and matched the expected value. It is a practical cross-check of one usage, not proof that every example elsewhere on this page is correct.
=GCD(12;18)
Expected result: 6.
Find the largest positive integer dividing both inputs.
If the result differs, check the referenced cells, argument separators and number formatting. For more information, consult the LibreOffice Calc official help.