From 1fdc7373670b644e6dcdb93efef08b8a4ec0c4c5 Mon Sep 17 00:00:00 2001 From: cxnnqr Date: Thu, 1 Feb 2024 23:05:49 +0100 Subject: [PATCH] refactoring: changed to Euclidean modulo algorithm --- src/ggT/ggT.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/ggT/ggT.c b/src/ggT/ggT.c index 484acb6..cccb8e9 100644 --- a/src/ggT/ggT.c +++ b/src/ggT/ggT.c @@ -2,12 +2,10 @@ int ggT(int a, int b){ - while(a != b){ - if(a < b){ - b -= a; - } else { - a -= b; - } + while (b != 0) { + int temp = b; + b = a % b; + a = temp; } return a; } \ No newline at end of file