mxnet.np.gcd

gcd(x1, x2, out=None, **kwargs)

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

Parameters
  • x2 (x1,) – The arrays for computing greatest common divisor. If x1.shape != x2.shape, they must be broadcastable to a common shape (which may be the shape of one or the other).

  • out (ndarray or None, optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned.

Returns

y – The greatest common divisor of the absolute value of the inputs This is a scalar if both x1 and x2 are scalars.

Return type

ndarray or scalar

See also

gcd()

The lowest common multiple

Examples

>>> np.gcd(12, 20)
4
>>> np.gcd(np.arange(6, dtype=int), 20)
array([20,  1,  2,  1,  4,  5], dtype=int64)