# 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('9b52fc5c-81d5-4ec1-a753-115ead5ff87f','d35fc30d-adcb-4324-abe8-72113ba0d0ae','f96505e5-3129-47a0-b772-40fb3bebcd68','../lite/tree/../notebooks/index.html?path=baca3721_69b3_44f8_8b72_6b62823de7d7.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="f96505e5-3129-47a0-b772-40fb3bebcd68" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('9b52fc5c-81d5-4ec1-a753-115ead5ff87f','f96505e5-3129-47a0-b772-40fb3bebcd68')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('9b52fc5c-81d5-4ec1-a753-115ead5ff87f','f96505e5-3129-47a0-b772-40fb3bebcd68')">Open In Tab</button></div><div id="d35fc30d-adcb-4324-abe8-72113ba0d0ae" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
