Skip to main content

LCM

Description​

Calculates the least common multiple (LCM) of two integers.Note that the result may overflow.

Syntax​

LCM(<a>, <b>)

Parameters​

ParameterDescription
<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