equal
deleted
inserted
replaced
2 while b != 0: |
2 while b != 0: |
3 a, b = b, a % b |
3 a, b = b, a % b |
4 return a |
4 return a |
5 |
5 |
6 if __name__ == '__main__': |
6 if __name__ == '__main__': |
7 tc1 = gcd(48, 64) |
7 for line in open('gcd_testcases.dat'): |
8 if tc1 != 16: |
8 values = line.split(', ') |
9 print "Test failed for the case a=48 and b=64. Expected 16. Obtained %d instead." % tc1 |
9 a = int(values[0]) |
10 exit(1) |
10 b = int(values[1]) |
|
11 g = int(values[2]) |
11 |
12 |
12 tc2 = gcd(44, 19) |
13 tc = gcd(a, b) |
13 if tc2 != 1: |
14 if tc != g: |
14 print "Test failed for the case a=44 and b=19. Expected 1. Obtained %d instead." % tc2 |
15 print "Test failed for the case a=%d and b=%d. Expected %d. Obtained %d instead." % (a, b, g, tc) |
15 exit(1) |
16 exit(1) |
16 |
17 |
17 print "All tests passed!" |
18 print "All tests passed!" |