tdd/math_utils/gcd.py
author Puneeth Chaganti <punchagan@fossee.in>
Mon, 31 Jan 2011 17:23:25 +0530
changeset 155 3efb70d2a02f
parent 118 513d43e25927
permissions -rw-r--r--
vcs: Change email id to fossee from gmail.

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()