# xarray.ufuncs.gcd

### xarray.ufuncs.gcd *= <xarray.ufuncs._binary_ufunc object>*

xarray specific variant of `numpy.gcd()`. Handles xarray objects by dispatching to the appropriate function for the underlying array type.

Documentation from numpy:

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

* **Parameters:**
  **x1, x2** ([array_like](https://numpy.org/doc/stable/glossary.html#term-array_like), [`int`](https://docs.python.org/3/builtins/functions.html#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`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray) or [scalar](../user-guide/terminology.html.md#term-scalar)) – The greatest common divisor of the absolute value of the inputs
  This is a scalar if both x1 and x2 are scalars.

#### SEE ALSO
[`lcm`](xarray.ufuncs.lcm.html.md#xarray.ufuncs.lcm)
: The lowest common multiple

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('7e69486c-42db-48e6-856a-9b3b2d27e147','179509da-66d8-438f-b074-c706fc4e42fb','b5fc79d3-4e66-4d6e-a385-f22f493a3d9b','../lite/tree/../notebooks/index.html?path=51c7e6e2_6ecf_4334_a90c_b3b7745981ae.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> import numpy as np
>>> 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])
```

<div id="b5fc79d3-4e66-4d6e-a385-f22f493a3d9b" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('7e69486c-42db-48e6-856a-9b3b2d27e147','b5fc79d3-4e66-4d6e-a385-f22f493a3d9b')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('7e69486c-42db-48e6-856a-9b3b2d27e147','b5fc79d3-4e66-4d6e-a385-f22f493a3d9b')">Open In Tab</button></div><div id="179509da-66d8-438f-b074-c706fc4e42fb" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
