From 5328dcef48669ac5980deb0d45afbc2f56f63d76 Mon Sep 17 00:00:00 2001 From: dreasty Date: Mon, 1 Oct 2018 09:52:21 +0300 Subject: [PATCH 1/2] Fixed bugs in gdc --- gcd.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gcd.py b/gcd.py index 5880a5b..812d207 100644 --- a/gcd.py +++ b/gcd.py @@ -1,13 +1,13 @@ # 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 a + b # Examples From 88bf6e21e4c2fdfe26e2732a8cb02cd078bc5ce3 Mon Sep 17 00:00:00 2001 From: Slava Sukhoy Date: Mon, 1 Oct 2018 21:53:31 +0300 Subject: [PATCH 2/2] Update gcd.py --- gcd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcd.py b/gcd.py index 812d207..9242705 100644 --- a/gcd.py +++ b/gcd.py @@ -1,6 +1,6 @@ # Wrong gcd find 5 mistakes -def gcd(a, b): +def gcd(a:int, b:int): assert a >= 0 and b >= 0 while a and b: if a > b: