From 9dd490bc484599786be78d28d7de36f598db21ca Mon Sep 17 00:00:00 2001 From: Pavlo Prokopets Date: Tue, 2 Oct 2018 14:34:24 +0300 Subject: [PATCH] fix bugs --- gcd.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gcd.py b/gcd.py index 5880a5b..4de0d6f 100644 --- a/gcd.py +++ b/gcd.py @@ -1,13 +1,14 @@ # Wrong gcd find 5 mistakes def gcd(a, b): - assert a <= 0 and b >= 0 + assert a > 0 and b > 0 while a and b: if a > b: - a = a / b + a = a % b else: - b = b / a - return min(a, b) + b = b % a + return max(a, b) +print (gcd(1071, 1029)) # Examples