flopscope.numpy.lcm
fnp.lcm(*args, **kwargs)[flopscope source][numpy source]
Returns the lowest common multiple of ``|x1|`` and ``|x2|``
Adapted from NumPy docs np.lcm
Cost
16×
Flopscope Context
Element-wise least common multiple.
Returns the lowest common multiple of |x1| and |x2|
Parameters
- x1, x2:array_like, int
Arrays of values. If
x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).
Returns
- y:ndarray or scalar
The lowest common multiple of the absolute value of the inputs This is a scalar if both
x1andx2are scalars.
See also
- we.flops.gcd The greatest common divisor
Examples
>>> import flopscope.numpy as fnp
>>> flops.lcm(12, 20)
60
>>> flops.lcm.reduce([3, 12, 20])
60
>>> flops.lcm.reduce([40, 12, 20])
120
>>> flops.lcm(flops.arange(6), 20)
array([ 0, 20, 20, 60, 20, 20])