From 9ed80a6f35a78c4d61c0e0b21f22c5a6c13f4b65 Mon Sep 17 00:00:00 2001 From: cxnnqr Date: Fri, 2 Feb 2024 12:38:16 +0100 Subject: [PATCH] refactoring: added comments for better understanding --- src/ggT/ggT.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ggT/ggT.c b/src/ggT/ggT.c index ac0dd30..7f28bbc 100644 --- a/src/ggT/ggT.c +++ b/src/ggT/ggT.c @@ -2,14 +2,16 @@ int ggT(int a, int b){ + // handles the case if both inputs are 0 if(a == 0 && b == 0){ return 0; - } else if(a == 0){ + } else if(a == 0){ // handles the case if first number is 0 return b; - } else if(b == 0){ + } else if(b == 0){ // handles the case if second number is 0 return a; } + // Euclidean algorithm with modulo for getting the ggT while (b != 0) { int temp = b; b = a % b;