GCD
The largest whole number that goes into both of two whole numbers without a remainder.
Group: Math. Compatible with DAX.
Syntax
GCD ( <number1>, <number2> )
| Parameter | Type | Description |
|---|---|---|
number1 | Whole number | A whole number of 0 or more. |
number2 | Whole number | A second whole number of 0 or more. |
Returns
Whole number. The greatest common divisor of the two; 0 when both are 0.
Remarks
- It takes exactly two numbers. For more, nest the calls:
GCD ( GCD ( 12, 18 ), 24 ). - Decimals are rounded to whole numbers first, a half away from zero:
GCD ( 24.6, 36 )isGCD ( 25, 36 ), 1. - When one number is 0 the other is the answer; a blank counts as 0. A negative number is an error.
Examples
Common divisors
EVALUATE
ROW (
"24 and 36", GCD ( 24, 36 ),
"12, 18 and 24", GCD ( GCD ( 12, 18 ), 24 ),
"7 and 0", GCD ( 7, 0 ),
"17 and 5", GCD ( 17, 5 )
)
| 24 and 36 | 12, 18 and 24 | 7 and 0 | 17 and 5 |
|---|---|---|---|
| 12 | 6 | 7 | 1 |