/* Derlemek icin gcc -o program_ismi 3.c */

#include <stdio.h>
#include <stdlib.h>

int min(int m, int n)
{
     if (n<m)
        return n;
     else
        return m;
}



int gcd(int m, int n)
{
	
	int lim=min (m,n);
	
	int i;
	for (i=lim; i>0; i--) {
		
		if (!(m%i) && !(n%i))     //if ((m%i)==0 && (n%i)==0) 
		    break;
	
	}
	    
	return i;
}


int main()
{	
	int a, b;
	
	printf("Calculating the greatest common divisor: \n");
	printf("Enter the values of a and b: \n");
	
	scanf("%d %d", &a, &b);
	
	printf("The greatest common divisor of %d and %d is %d\n", a, b, gcd(a,b));
	
	system("pause");
	
	return 0;
}
