Skip to main content

GCD

Description

Calculates the greatest common divisor (GCD) of two integers.

Syntax

GCD(<a>, <b>)

Parameters

ParameterDescription
<a>The first integer
<b>The second integer

Return Value

Returns the greatest common divisor of <a> and <b>.

Examples

select gcd(54, 24);
+------------+
| gcd(54,24) |
+------------+
| 6 |
+------------+
select gcd(-17, 31);
+-------------+
| gcd(17,31) |
+-------------+
| 1 |
+-------------+
select gcd(0, 10);
+-----------+
| gcd(0,10) |
+-----------+
| 10 |
+-----------+