From 7a9de12f857041e10e2b2a9312a7986806d1762b Mon Sep 17 00:00:00 2001 From: Igor Tagintsev Date: Sat, 29 Sep 2018 14:58:33 +0300 Subject: [PATCH] Fix Bug --- gcd.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/gcd.py b/gcd.py index a5a8991..229aa72 100644 --- a/gcd.py +++ b/gcd.py @@ -4,12 +4,10 @@ def gcd(a, b): assert a >= 0 and b >= 0 while a and b: if a > b: - a = a / b - break + a = a % b else: - b = b / a - break - return min(a, b) + b = b % a + return a + b print(gcd(10, 0)) @@ -18,4 +16,4 @@ def gcd(a, b): # gcd(10, 0) => 10 # gcd(123, 3) => 3 # gcd(1000000, 64) => 64 -# gcd(0, 0) => 0 +# gcd(0, 0) => 0 \ No newline at end of file