#include
#include
int gcd(int no1,int no2)
{
int greater,smaller,c;
if(no1>no2)
{
greater=no1;
smaller=no2;
}
else
{
greater=no2;
smaller=no1;
}
while(smaller!=0)
{
c=greater%smaller;
greater=smaller;
smaller=c;
}
return greater;
}
int main()
{
int a,b,c;
printf("please enter two positive integers \n");
scanf("%i %i",&a,&b);
c=gcd(a,b);
printf("GCD of %d and %d is :%d \n",a,b,c);
getch();
return 0;
}
No comments:
Post a Comment