``````

In [1]:

import numpy as np

``````
``````

In [2]:

a = np.array([0, 2, 3, 6])
b = np.array([3, 4, 5, 15])

``````
``````

In [3]:

print(np.gcd(a, b))

``````
``````

[3 2 1 3]

``````
``````

In [4]:

print(type(np.gcd(a, b)))

``````
``````

<class 'numpy.ndarray'>

``````
``````

In [5]:

l_a = [0, 2, 3, 6]
l_b = [3, 4, 5, 14]

``````
``````

In [6]:

print(np.gcd(l_a, l_b))

``````
``````

[3 2 1 2]

``````
``````

In [7]:

print(type(np.gcd(l_a, l_b)))

``````
``````

<class 'numpy.ndarray'>

``````
``````

In [8]:

print(np.gcd(6, 15))

``````
``````

3

``````
``````

In [9]:

print(type(np.gcd(6, 15)))

``````
``````

<class 'numpy.int64'>

``````
``````

In [10]:

a_2d = np.array([[0, 2, 3, 6], [0, 2, 3, 6]])
print(a_2d)

``````
``````

[[0 2 3 6]
[0 2 3 6]]

``````
``````

In [11]:

print(b)

``````
``````

[ 3  4  5 15]

``````
``````

In [12]:

print(a_2d + b)

``````
``````

[[ 3  6  8 21]
[ 3  6  8 21]]

``````
``````

In [13]:

print(np.gcd(a_2d, b))

``````
``````

[[3 2 1 3]
[3 2 1 3]]

``````
``````

In [14]:

a_mismatch = np.array([0, 1, 2])

``````
``````

In [15]:

# print(np.gcd(a_mismatch, b))
# ValueError: operands could not be broadcast together with shapes (3,) (4,)

``````
``````

In [16]:

print(np.gcd(a, 15))

``````
``````

[15  1  3  3]

``````
``````

In [17]:

print(np.gcd(15, a))

``````
``````

[15  1  3  3]

``````