#include <stdio.h>
#include <stdlib.h>
int gcd(int m, int n)
{
int rem;
while(n > 0)
{
rem = m % n;
m = n;
n = rem;
}
return m;
}
int main()
{
int m, n;
printf("Please input two numbers: \n");
scanf("%d %d", &m, &n);
if(m > n)
printf("the max gcd of the two number is: %d\n", gcd(m,n));
else
printf("the max gcd of the two number is: %d\n", gcd(n,m));
return 0;
}
计算最大公因数的欧几里德算法
最新推荐文章于 2023-08-09 16:48:26 发布