From 7f6285bb904ae4fef879e26394fd35636a6022e0 Mon Sep 17 00:00:00 2001 From: Zhovna Roman Date: Sat, 29 Sep 2018 18:28:31 +0300 Subject: [PATCH] bugs are fixed --- gcd.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gcd.py b/gcd.py index 5880a5b..255c050 100644 --- a/gcd.py +++ b/gcd.py @@ -1,14 +1,15 @@ # 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(12,10)) # Examples # gcd(10, 0) => 10