tdd/gcd.py
changeset 111 a6a442d1bbd9
child 114 83b3e357ed08
equal deleted inserted replaced
110:4e7b98636b58 111:a6a442d1bbd9
       
     1 def gcd(a, b):
       
     2     while b != 0:
       
     3         a, b = b, a % b
       
     4     return a
       
     5 
       
     6 if __name__ == '__main__':
       
     7     tc1 = gcd(48, 64)
       
     8     if tc1 != 16:
       
     9         print "Test failed for the case a=48 and b=64. Expected 16. Obtained %d instead." % tc1
       
    10         exit(1)
       
    11 
       
    12     tc2 = gcd(44, 19)
       
    13     if tc2 != 1:
       
    14         print "Test failed for the case a=44 and b=19. Expected 1. Obtained %d instead." % tc2
       
    15         exit(1)
       
    16 
       
    17     print "All tests passed!"