tdd/math_utils/gcd.py
author Madhusudan.C.S <madhusudancs@gmail.com>
Tue, 07 Sep 2010 15:16:40 +0530
changeset 128 29e6b1d5e5f5
parent 118 513d43e25927
permissions -rw-r--r--
Add third lab exercise questions.

def gcd(a, b):
    """Returns the Greatest Common Divisor of the two integers
    passed as arguments.

    Args:
      a: an integer
      b: another integer

    Returns: Greatest Common Divisor of a and b

    >>> gcd(48, 64)
    16
    >>> gcd(44, 19)
    1
    """
    if b == 0:
        return b
    return gcd(b, a%b)

if __name__ == "__main__":
    import doctest
    doctest.testmod()