math.lcm(*integers) function returns the Least Common Multiple (LCM) of the integers passed as arguments.
The syntax to call lcm() function is
|*integers||No||None, one or multiple integer values.|
If no integer value is passed as argument to lcm(), then the return value is 1.
If only one integer is passed to lcm(), then then same value is returned as LCM.
If any non-integral value is passed as argument to lcm(), then the function raises TypeError.
1. LCM of two integers
In the following program, we find the LCM of two integers: 10 and 25.
lcm() : 50
2. LCM of one integer
In the following program, we find the LCM of a single integer value: 5.
lcm() : 5
3. LCM of float values
In the following program, we try to find the LCM of floating point values. math.lcm() throws TypeError, because the method accepts only integer values.
TypeError: 'float' object cannot be interpreted as an integer
In this Python Math tutorial, we learned the syntax of, and examples for math.lcm() function.