Saiful's World
Saturday, January 21, 2012
Standard GCD(Greatest Common Devisor)
#include<stdio.h>
int GCD(int a,int b)
{
int c;
while(b > 0)
{
c = a%b;
a = b; b = c;
}
return a;
}
int main()
{
int i,n,a,b;
while(scanf("%d%d",&a,&b)==2)
{
printf("%d\n",GCD(a,b));
}
return 0;
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment