From 4058a733a90b52a3dbb87ccfba03c2aac19f3afb Mon Sep 17 00:00:00 2001 From: freezed <2160318-free_zed@users.noreply.gitlab.com> Date: Tue, 13 Apr 2021 23:51:07 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Implement=20greater=20common=20divi?= =?UTF-8?q?sor=20algorithm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit relate to forga/process/fr/embarquement#6 --- tuto-pysdur/pgcd.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tuto-pysdur/pgcd.py b/tuto-pysdur/pgcd.py index 473cd45..75b9864 100644 --- a/tuto-pysdur/pgcd.py +++ b/tuto-pysdur/pgcd.py @@ -18,4 +18,17 @@ def pgcd(a,b): This function find the Greatest Common Divisor (PGCD in French) between a & b """ - pass + rest = a - b + check = b - rest + + while check != 0: + a = max(b, rest) + b = min(b, rest) + rest = a - b + check = max(b, rest) - min(b, rest) + + print(rest) + + +if __name__ == '__main__': + pgcd(561, 357)