Let us take back our time.

## Function Syntax

GCD or Greatest Common Divisor is the greatest positive value that can divide two or more numbers.

The gcd function in NumPy has a syntax as shown:

Despite the crazy-looking syntax, you only need to worry about two parameters, as shown:

- x1 and x2 – refer to the input arrays.

## Example #1

The code below shows using the gcd() function with two scalar values.

import numpy as np

print(f"gcd: {np.gcd(130, 13)}")

The above code should return the GCD of 130 and 13 as shown:

## Example #2

To get the GCD of two arrays, we can do:

arr_2 = np.array([14,145,15])

print(f"gcd: {np.gcd(arr_1, arr_2)}")

The code above should return:

## Example #3

You can also determine the GCD of an element of arrays and a scalar value. For example:

print(f"GCD: {np.gcd(arr, 5)}")

The example code above should return the GCD of the array, and 5.

## Closing

This tutorial walks through how to calculate the GCD of array elements along a given axis.

Thanks for reading!!