changeset 118 | 513d43e25927 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tdd/math_utils/gcd.py Fri Sep 03 11:51:18 2010 +0530 @@ -0,0 +1,22 @@ +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()