Computing the greatest common divisor of two positive integers via Euclid's algorithm must return a positive value that evenly divides both original inputs.
from hypothesis import given, strategies as st
@given(st.integers(min_value=1, max_value=10_000), st.integers(min_value=1, max_value=10_000))
def test_gcd_divides_both_inputs(a, b):
result = IMPL(a, b)
assert result > 0
assert a % result == 0
assert b % result == 0
def gcd(a, b):
a, b = abs(a), abs(b)
while b:
a, b = b, b % a
return a
def gcd(a, b):
a, b = abs(a), abs(b)
while b:
a, b = b, a % b
return a