The math.gcd()
function is used to get the greatest common divisor (GCD) of two or more integers. The GCD of given numbers is the largest positive integer that divides all of the integers without a remainder.
For example the GCD of 12 and 15 is 3, because 3 is the largest number that can divide both 12 and 15 without a remainder.
math.gcd(*args)
Where, parameter args
represents the arbitrary integer arguments that can be passed to the function. The arguments should have a minimum of 2 integers.
The arguments passed to the math.gcd()
function should be strictly integers. Otherwise a TypeError
is raised.