CKTIS / Python
math.lcm
Computes the nonnegative least common multiple of integer arguments.
Version: Python 3.14; repository image, production runtime not attested
Syntax
math.lcm(*integers)Computes the nonnegative least common multiple of integer arguments.
A zero factor produces zero, whereas a call with no arguments returns one.
Twelve is the smallest positive multiple of both 4 and 6. Signs do not affect that result. Any zero argument makes the common multiple zero. With no arguments, the identity is one, so adjoining a single positive integer reproduces that integer.
import math
assert math.lcm(-4, 6) == 12 and math.lcm(0, 6) == 0
assert math.lcm() == 1
Examples
import math
print(math.lcm(-4, 6))
print((math.lcm(0, 6), math.lcm()))
Result
12 (0, 1)
Twelve is the smallest positive multiple of both 4 and 6. Signs do not affect that result. Any zero argument makes the common multiple zero. With no arguments, the identity is one, so adjoining a single positive integer reproduces that integer.