math module

math_utilities

py_utilities.math.math_utilities.gcd(a, b)[source]

Returns the greatest common divisor using Euclid’s algo

>>> gcd(12, 24)
12
>>> gcd(48, 4)
4
>>> gcd(2, 4)
2
>>> gcd(36, 48)
12
py_utilities.math.math_utilities.gcd_seq(seq)[source]

Returns the greatest common divisor of seq

>>> gcd_seq([12, 24, 48])
12
py_utilities.math.math_utilities.lcm(a, b)[source]

Returns lowest common multiple

>>> lcm(4, 8)
8