#include<stdio.h>
int main()
{
int n, m, a,b,i;
printf("请输入m和n的值:");
scanf("%d%d", &n, &m);
b = n;
i = m;
while (m != 0)
{
a = n % m;
n = m;
m = a;
}
printf("最大公约数为:%d\n", n);
i = (b * i) / n;
printf("最小公倍数为;%d\n", i);
return 0;
}
简单思维与简单代码理解最小公倍数与最大公因数
最新推荐文章于 2024-08-17 23:16:58 发布