Calculates the greatest common divisor (GCD) of two integers.
GCD(<a>, <b>)
| Parameter | Description |
|---|---|
<a> | The first integer |
<b> | The second integer |
Returns the greatest common divisor of <a> and <b>. If any input is NULL, returns NULL.
select gcd(54, 24);
+------------+ | gcd(54,24) | +------------+ | 6 | +------------+
select gcd(-17, 31);
+--------------+ | gcd(-17,31) | +--------------+ | 1 | +--------------+
select gcd(0, 10);
+-----------+ | gcd(0,10) | +-----------+ | 10 | +-----------+
select gcd(54, NULL);
+---------------+ | gcd(54, NULL) | +---------------+ | NULL | +---------------+