题解 | #求最小公倍数#
求最小公倍数
https://www.nowcoder.com/practice/22948c2cad484e0291350abad86136c3
#include<stdio.h>
int getmin(int a,int b)
{
while(b!=0)
{
int temp=a%b;
a=b;
b=temp;
}
return a;
}
int main()
{
int a=0;
int b=0;
scanf("%d %d",&a,&b);
int ret=getmin(a,b);
printf("%d",a*b/ret);
return 0;
}
int getmin(int a,int b)
{
while(b!=0)
{
int temp=a%b;
a=b;
b=temp;
}
return a;
}
int main()
{
int a=0;
int b=0;
scanf("%d %d",&a,&b);
int ret=getmin(a,b);
printf("%d",a*b/ret);
return 0;
}