From 2a27e93d1cbbb727c3a87b7fca0a67a5d961d2e0 Mon Sep 17 00:00:00 2001 From: fsharpasharp Date: Thu, 19 Oct 2017 10:19:44 +0200 Subject: [PATCH] Concise version --- misc/GCD.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/misc/GCD.c b/misc/GCD.c index 94f14b8b..771d25cf 100644 --- a/misc/GCD.c +++ b/misc/GCD.c @@ -2,14 +2,9 @@ // Euclid's algorithm int GCD(int x, int y) { - if (x == y || y == 0) + if (y == 0) return x; - if (x == 0) - return y; - if (x > y) - return GCD(x-y, y); - else - return GCD(x, y-x); + return GCD(y, x%y); } int main() {