#include<stdio.h>
unsigned int greatest_common_factor( unsigned int M, unsigned int N ){
unsigned int Rem;
while( N > 0 ){
Rem = M % N;
M = N;
N = Rem;
}
return M;
}
int main()
{
int temp;
int a,b;
scanf("%d",&a);
scanf("%d",&b);
printf("the greatest common factor of %d and %d is ",a,b);
printf("%d\n",greatest_common_factor(a,b));
getchar();
return getchar();
}
this is a demo from ischarles.