ReferenceFunctionsMath Functions
GCD
GCD: Returns the greatest common divisor of one or more integers.
Summary
GCD truncates each argument toward zero before calculating the divisor.
Remarks
- Inputs must be between
0and9.99999999e9after truncation, or#NUM!is returned. - Negative values return
#NUM!. - Any argument error propagates immediately.
Examples
Greatest common divisor of two numbers
Grid
| Cell | Value | |
|---|---|---|
| No inputs on Sheet1. | ||
Formula
=
Result
Not evaluated yet.
Expected
12
Variadic and fractional arguments
Grid
| Cell | Value | |
|---|---|---|
| No inputs on Sheet1. | ||
Formula
=
Result
Not evaluated yet.
Expected
6
Negative values are invalid
Grid
| Cell | Value | |
|---|---|---|
| No inputs on Sheet1. | ||
Formula
=
Result
Not evaluated yet.
Expected
#NUM!
Related functions
FAQ
What happens to decimal inputs in GCD?
Each argument is truncated toward zero before the divisor is computed.
When does GCD return #NUM!?
Negative values or values outside the supported bound return #NUM!.
Runtime metadata
Category
Math
Signature
GCD(arg1: Number, arg2…: Number)Arity
min 1, max variadic
Arguments
arg1Number · Scalar · coercion NumberLenientText
arg2Number · Scalar · coercion NumberLenientText
Caps
PURE
Source