This is a pre-release version (2.5.0.dev0+git20251130.2de293a).Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.5.0.dev0+git20251130.2de293a / numpy / gcd

ufunc

numpy:gcd

source: /dev/numpy/build-install/usr/lib/python3.14/site-packages/numpy/__init__.py

Summary

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

Parameters

x1, x2 : array_like, int

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

Returns

y : ndarray or scalar

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

Examples

import numpy as np
✓
np.gcd(12, 20)
np.gcd.reduce([15, 25, 35])
✗
np.int64(5)
np.gcd(np.arange(6), 20)
✓
array([20,  1,  2,  1,  4,  5])

See also

lcm

The lowest common multiple

Aliases

  • numpy.gcd