From d00979ac6d130ad45b845f30d796e2ce7582ea68 Mon Sep 17 00:00:00 2001 From: Apestin-Ilya Date: Mon, 8 Oct 2018 13:54:41 +0300 Subject: [PATCH] Bug is fixed --- gcd.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gcd.py b/gcd.py index 5880a5b..9f077f6 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 - 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 max(a, b) # Examples