From 6dfc92e3dc2f3d1f2da5e8573f952de2437ae8e5 Mon Sep 17 00:00:00 2001 From: Shaquille Soekhlal Date: Wed, 11 Sep 2019 11:26:22 +0200 Subject: [PATCH] Made it iterative --- Assignment 5/main.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Assignment 5/main.c b/Assignment 5/main.c index 64bb724..8883acc 100644 --- a/Assignment 5/main.c +++ b/Assignment 5/main.c @@ -9,14 +9,18 @@ int gcd (int p, int q) { - int r; - - if ((r = p % q) == 0) - return q; - else - return gcd (q, r); + int r,t; + while (q > 0) + { + r = p%q; + p=q; + q=r; + } + return p; } + + int main(){ int a,b; scanf("%d%d",&a,&b);