From 6aad7be0b25ad05deec982393d1576520c504b5e Mon Sep 17 00:00:00 2001 From: cxnnqr Date: Fri, 2 Feb 2024 12:49:10 +0100 Subject: [PATCH] refactoring: simplified the zero cases --- src/ggT/ggT.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/ggT/ggT.c b/src/ggT/ggT.c index 7f28bbc..ef9b8ef 100644 --- a/src/ggT/ggT.c +++ b/src/ggT/ggT.c @@ -2,14 +2,9 @@ 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){ // handles the case if first number is 0 - return b; - } else if(b == 0){ // handles the case if second number is 0 - return a; - } + // handles the zero cases + if(a == 0) return b; + if(b == 0) return a; // Euclidean algorithm with modulo for getting the ggT while (b != 0) {