LCM
Descriptionβ
Calculates the least common multiple (LCM) of two integers.Note that the result may overflow.
Syntaxβ
LCM(<a>, <b>)
Parametersβ
Parameter | Description |
---|---|
<a> | The first integer |
<b> | The second integer |
Return Valueβ
Returns the least common multiple of <a>
and <b>
.
Examplesβ
select lcm(12, 18);
+------------+
| lcm(12,18) |
+------------+
| 36 |
+------------+
select lcm(0, 10);
+-----------+
| lcm(0,10) |
+-----------+
| 0 |
+-----------+
select lcm(-4, 6);
+------------+
| lcm(-4,6) |
+------------+
| 12|
+------------+
select lcm(-170141183460469231731687303715884105728, 3);
ERROR 1105 (HY000): errCode = 2, detailMessage = Can not convert to legacy literal: 510423550381407695195061911147652317184