Curriculum
Course: NumPy
Login

Curriculum

NumPy

Text lesson

ufunc Finding LCM

Finding LCM (Lowest Common Multiple)

The lowest common multiple (LCM) is the smallest number that is a multiple of two given numbers.

Example

Calculate the lowest common multiple (LCM) of the following two numbers:

import numpy as np

num1 = 4
num2 = 6

x = np.lcm(num1, num2)

print(x)
Returns: 12, as it is the lowest common multiple of both numbers (4 × 3 = 12 and 6 × 2 = 12).