lcm#

ivy.lcm(x1, x2, /, *, out=None)[source]#

Compute the element-wise least common multiple (LCM) of x1 and x2.

Parameters:
  • x1 (Union[Array, NativeArray]) – first input array, must be integers

  • x2 (Union[Array, NativeArray]) – second input array, must be integers

  • out (Optional[Array], default: None) – optional output array, for writing the result to.

Return type:

Array

Returns:

ret – an array that includes the element-wise least common multiples of x1 and x2

Examples

With ivy.Array input:

>>> x1=ivy.array([2, 3, 4])
>>> x2=ivy.array([5, 7, 15])
>>> x1.lcm(x1, x2)
ivy.array([10, 21, 60])
Array.lcm(self, x2, *, out=None)[source]#

ivy.Array instance method variant of ivy.lcm. This method simply wraps the function, and so the docstring for ivy.lcm also applies to this method with minimal changes.

Parameters:
  • self (Array) – first input array.

  • x2 (Array) – second input array

  • out (Optional[Array], default: None) – optional output array, for writing the result to.

Return type:

Array

Returns:

ret – an array that includes the element-wise least common multiples of ‘self’ and x2

Examples

>>> x1=ivy.array([2, 3, 4])
>>> x2=ivy.array([5, 8, 15])
>>> x1.lcm(x2)
ivy.array([10, 21, 60])
Container.lcm(self, x2, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.lcm. This method simply wraps the function, and so the docstring for ivy.lcm also applies to this method with minimal changes.

Parameters:
  • x1 – first input container.

  • x2 (Union[Container, Array, NativeArray]) – second input container.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – a container containing the the element-wise least common multiples of the arrays contained in x1 and x2.

Examples

>>> x1=ivy.Container(a=ivy.array([2, 3, 4]),
...                  b=ivy.array([6, 54, 62, 10]))
>>> x2=ivy.Container(a=ivy.array([5, 8, 15]),
...                  b=ivy.array([32, 40, 25, 13]))
>>> x1.lcm(x2)
{
    a: ivy.array([10, 24, 60]),
    b: ivy.array([96, 1080, 1550, 130])
}