close
#include <stdio.h>
/* while loop GCD */
int GCD(int a,int b)
{
while(a%b!=0)
{
b=a%b;
}
return b;
}
int main()
{
printf("Input a and b:\n");
int a,b;
scanf("%d%d",&a,&b);
int t1,t2;
t1=a;
t2=b;
int temp;
if(a<b)
{
temp=a;
a=b;
b=temp;
}
printf("GCD(%d,%d)=%d",t1,t2,GCD(a,b));
}
全站熱搜
留言列表