1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-11-23 15:48:42 +00:00
202401-programming-assignments/【实践课外】4.循环结构1/7-1 最大公约数和最小公倍数.c

21 lines
274 B
C
Raw Normal View History

2024-10-25 08:43:54 +00:00
#include <stdio.h>
int gcd(int x, int y) {
if (x == 0) return y;
return gcd(y % x, x);
}
int lcm(int x, int y) {
return x / gcd(x, y) * y;
}
int main() {
int m, n;
scanf("%d%d", &m, &n);
printf("%d %d\n", gcd(m, n), lcm(m, n));
return 0;
}