From d76b8867fea6f4885d6d7fa552e661e5ceb2ba13 Mon Sep 17 00:00:00 2001 From: cxnnqr Date: Thu, 1 Feb 2024 23:07:58 +0100 Subject: [PATCH] added edge cases for one or both numbers = 0 --- src/ggT/ggT.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ggT/ggT.c b/src/ggT/ggT.c index cccb8e9..ac0dd30 100644 --- a/src/ggT/ggT.c +++ b/src/ggT/ggT.c @@ -2,6 +2,14 @@ int ggT(int a, int b){ + if(a == 0 && b == 0){ + return 0; + } else if(a == 0){ + return b; + } else if(b == 0){ + return a; + } + while (b != 0) { int temp = b; b = a % b;