求两个数最大公约数

/思路:方法;欧几里得定理(辗转相除法)
1,用两个数相除取余数
2,再用除数与余数再去第二个余数
核心代码;int a,b,c;
c = a % b;
a = b;
b = c;
/
#include
unsigned int Gcd(unsigned int ,unsigned int );//函数原型
int main()
{
int a,b;
scanf("%d %d",&a,&b);
printf("%d\n",Gcd(a , b));
return 0;

}
unsigned int Gcd(unsigned int M ,unsigned int N)
{
unsigned int Rem;
while(N > 0)
{
Rem = M % N;
M = N;
N = Rem;

}
return M;

}

你可能感兴趣的:(求两个数最大公约数)