VeloDB Cloud 26.x·Apache Doris 4.x (up to 4.0 supported)·"Since X.Y" tags refer to Apache Doris versionsVersion mapping
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>.
If any input is NULL, returns NULL.
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
select lcm(-4, NULL);
+---------------+
| lcm(-4, NULL) |
+---------------+
| NULL |
+---------------+