numpy.gcd#

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

Returns the greatest common divisor of|x1| and|x2|

Parameters:
x1, x2array_like, int

Arrays of values.Ifx1.shape!=x2.shape, they must be broadcastable to a commonshape (which becomes the shape of the output).

Returns:
yndarray or scalar

The greatest common divisor of the absolute value of the inputsThis is a scalar if bothx1 andx2 are scalars.

See also

lcm

The lowest common multiple

Examples

>>>importnumpyasnp>>>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])
On this page