# include <stdio.h>
# include <math.h>
int main()
{
int m, n, i = 0, c = 0;
printf("m=");
scanf_s("%d", &m);
printf("n=");
scanf_s("%d", &n);
if (m > n)
for (i = m;i > 0;i--)
if (m % i == 0 && n % i == 0) break;
}
printf("兩個數的最大公約數為:%d", i);
else
for (i = n; i > 0;i--)
for (c = m;c < 30000;c++)
if (c % m == 0 && c % n == 0) break;
printf("兩個數的最小公倍數為:%d", c);
for (c = n;c < 30000 ;c++)
return 0;
# include <stdio.h>
# include <math.h>
int main()
{
int m, n, i = 0, c = 0;
printf("m=");
scanf_s("%d", &m);
printf("n=");
scanf_s("%d", &n);
if (m > n)
{
for (i = m;i > 0;i--)
{
if (m % i == 0 && n % i == 0) break;
}
printf("兩個數的最大公約數為:%d", i);
}
else
{
for (i = n; i > 0;i--)
{
if (m % i == 0 && n % i == 0) break;
}
printf("兩個數的最大公約數為:%d", i);
}
if (m > n)
{
for (c = m;c < 30000;c++)
{
if (c % m == 0 && c % n == 0) break;
}
printf("兩個數的最小公倍數為:%d", c);
}
else
{
for (c = n;c < 30000 ;c++)
{
if (c % m == 0 && c % n == 0) break;
}
printf("兩個數的最小公倍數為:%d", c);
}
return 0;
}