예제 #1
0
def gcd(*numbers):
    """
    Get a greatest common divisor for a list of numbers
    """
    n = numbers[0]
    for i in numbers:
        n = pygcd(n, i)
    return n
예제 #2
0
def gcd(*numbers):
    """
    Returns the greatest common divisor for a sequence of numbers.

    Args:
        \*numbers: Sequence of numbers.

    Returns:
        (int) Greatest common divisor of numbers.
    """
    n = numbers[0]
    for i in numbers:
        n = pygcd(n, i)
    return n
예제 #3
0
def gcd(*numbers):
    """
    Returns the greatest common divisor for a sequence of numbers.

    Args:
        \*numbers: Sequence of numbers.

    Returns:
        (int) Greatest common divisor of numbers.
    """
    n = numbers[0]
    for i in numbers:
        n = pygcd(n, i)
    return n
예제 #4
0
 def test_gcd_random_large(self):
     """Test the gcd function using random integers until 1 billion."""
     m = randint(1, 1000000000)
     n = randint(1, 1000000000)
     GCD = gcd_recursive(m, n)
     self.assertEqual(GCD, pygcd(m, n))
예제 #5
0
 def test_gcd_random_small(self):
     """Test the gcd function using random integers until 1000."""
     m = randint(1, 1000)
     n = randint(1, 1000)
     GCD = gcd2(m, n)
     self.assertEqual(GCD, pygcd(m, n))