Made it iterative

This commit is contained in:
Shaquille Soekhlal 2019-09-11 11:26:22 +02:00
parent db0f0eab11
commit 6dfc92e3dc

View File

@ -9,13 +9,17 @@
int gcd (int p, int q) int gcd (int p, int q)
{ {
int r; int r,t;
while (q > 0)
if ((r = p % q) == 0) {
return q; r = p%q;
else p=q;
return gcd (q, r); q=r;
} }
return p;
}
int main(){ int main(){
int a,b; int a,b;