From 3fb0878afcdbc7166df87373d2e88f132a76f51c Mon Sep 17 00:00:00 2001 From: Daria-Homenko <43683023+Daria-Homenko@users.noreply.github.com> Date: Tue, 2 Oct 2018 22:28:53 +0300 Subject: [PATCH] Fix 5 mistakes --- gcd.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/gcd.py b/gcd.py index 5880a5b..75919ea 100644 --- a/gcd.py +++ b/gcd.py @@ -1,13 +1,11 @@ -# Wrong gcd find 5 mistakes - def gcd(a, b): - assert a <= 0 and b >= 0 - while a and b: + assert a >= 0 and b >= 0 + while a != 0 and b != 0: if a > b: - a = a / b + a = a % b else: - b = b / a - return min(a, b) + b = b % a + return (a+b) # Examples