Sunday, March 18, 2012

exercise 6.8 - gcd


""" ========================
exercise 6.8
========================="""

def gcd(a, b):
    if b == 0:
        return a
    else:
        r = a % b
        # print b, " , ", r # print this line to see intermediary steps
        return gcd(b,r)


print "gcd(1989,867) = ", gcd(1989,867)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.