NumPy参考 >例行程序 >Mathematical functions > numpy.gcd
numpy.
gcd
(X1,X2,/,出=无,*,其中=真,铸造= 'same_kind' ,为了= 'K' ,D型细胞=无,subok =真[,签名,extobj ] )= <ufunc 'GCD'> ¶返回|x1|
和的最大公约数。|x2|
值数组。如果为,则必须将它们广播为通用形状(成为输出的形状)。x1.shape != x2.shape
输入的绝对值的最大公约数。如果x1和x2均为标量,则这是标量。
也可以看看
lcm
最低公倍数
例子
>>> np.gcd(12, 20)
4
>>> np.gcd.reduce([15, 25, 35])
5
>>> np.gcd(np.arange(6), 20)
array([20, 1, 2, 1, 4, 5])