#include<stdio.h>
int Gcd(int x,int y);
int main()
{
int a,b;
int result;
printf("Input a,b:");
scanf("%d,%d",&a,&b);
result = Gcd(a,b);
if(result == -1)
printf("Input number should be positive!");
else
{
printf("Greatest Common Divisor of %d and %d is %d",a,b,result);
}
return 0;
}
int Gcd(int x,int y)
{
if(x <= 0 || y <= 0)
{
return -1;
}
else
{
int min,i;
min = x < y ? x:y;
for(i=min;i>=1;i--)
{
if(x%i==0 && y%i==0)
{
return i;
}
}
}
}