#include<stdio.h>
int gcd(int a, int b){
return b != 0 ? gcd(b, a%b) : a;
}
int main(){
int a, b;
while (scanf("%d%d",&a,&b)!=EOF)
{
printf("%d\n", a*b / gcd(a, b));
}
}
王道机试4.5:最小公倍数(LCM)
最新推荐文章于 2020-04-01 11:06:20 发布
#include<stdio.h>
int gcd(int a, int b){
return b != 0 ? gcd(b, a%b) : a;
}
int main(){
int a, b;
while (scanf("%d%d",&a,&b)!=EOF)
{
printf("%d\n", a*b / gcd(a, b));
}
}