diff options
Diffstat (limited to 'testing_and_debugging/gcd.py')
-rw-r--r-- | testing_and_debugging/gcd.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/testing_and_debugging/gcd.py b/testing_and_debugging/gcd.py index 5bc9110..7cbb9a0 100644 --- a/testing_and_debugging/gcd.py +++ b/testing_and_debugging/gcd.py @@ -1,11 +1,25 @@ def gcd(a, b): - if a%b==0: + if b==0: return a return gcd(b, a%b) #if __name__ == '__main__': # result = gcd(48, 64) -# if result != 16: +# if result!= 16: # print "Test failed" # print "Test Passed" + + +#if __name__ == '__main__': +# for line in open('testcases.txt'): +# numbers = line.split() +# x = int(numbers[0]) +# y = int(numbers[1]) +# result = int(numbers[2]) +# if gcd(x, y) != result: +# print "Failed gcd test for", x, y +# else: +# print "Test passed" , result + + |