# 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('8c47c740-611a-4f8b-84ea-c0cdb6537477','c8554d6f-47ea-42d1-8e02-5c3c2f1b4593','010df8bf-ec84-4294-9164-46ff0688d3ab','../lite/tree/../notebooks/index.html?path=9f641fb4_ad0b_41cb_904e_ce5df04a1c38.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="010df8bf-ec84-4294-9164-46ff0688d3ab" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('8c47c740-611a-4f8b-84ea-c0cdb6537477','010df8bf-ec84-4294-9164-46ff0688d3ab')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('8c47c740-611a-4f8b-84ea-c0cdb6537477','010df8bf-ec84-4294-9164-46ff0688d3ab')">Open In Tab</button></div><div id="c8554d6f-47ea-42d1-8e02-5c3c2f1b4593" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
