Facebook Page Twitter Page LinkedIn Page
× Python Tutorial Python Advanced Python Resources Python Libraries


The Python math.lcm() function is used to return the least common multiple of the specified integer arguments. If all arguments are nonzero, then the returned value is the smallest positive integer which is a multiple of all arguments. If any of the arguments is zero, then the returned value is 0. If no arguments is provided, it returns 1.

For example - LCM of 20 and 25 is 100, and LCM of 50 and 100 is 100.

Note: This function is added in version 3.9.

Syntax

#New in version 3.9
math.lcm(*args)

Parameters

*args Required. Specify the variable number of integer values separated by comma (,).

Return Value

Returns the LCM of the specified arguments.

Example:

In the below example, lcm() function is used to return the LCM of the specified arguments.

import math

print(math.lcm(10, 20, 25))
print(math.lcm(4, 5))

The output of the above code will be:

100
20

❮ Python Math Module