当前位置: 首页>>编程示例 >>用法及示例精选 >>正文


Python numpy lcm用法及代码示例

本文简要介绍 python 语言中 numpy.lcm 的用法。

用法:

numpy.lcm(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True [, signature, extobj ]) = <ufunc 'lcm'>

返回 |x1||x2| 的最小公倍数

参数

x1, x2 数组样,int

值数组。如果 x1.shape != x2.shape ,它们必须可以广播到一个公共形状(成为输出的形状)。

返回

y ndarray 或标量

输入绝对值的最小公倍数 如果 x1 和 x2 都是标量,则这是一个标量。

例子

>>> np.lcm(12, 20)
60
>>> np.lcm.reduce([3, 12, 20])
60
>>> np.lcm.reduce([40, 12, 20])
120
>>> np.lcm(np.arange(6), 20)
array([ 0, 20, 20, 60, 20, 20])

相关用法


注:本文由纯净天空筛选整理自numpy.org大神的英文原创作品 numpy.lcm。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。