●求两个数的最小公倍数
int LeaComMul(int a,int b)
{
int i=1;
while((a*i)%b!=0) //通过a*i求出能够被b整除的最小的数
{
i++;
}
return a*i;
}
int main()
{
int a;
int b;
int n=0;
printf("请输入两个数:");
scanf("%d %d",&a,&b);
n=LeaComMul(a,b);
printf("%d和%d的最小公倍数是:%d",a,b,n);
return 0;
}
How to find the least common multiple of two numbers (the most direct method)
Guess you like
Origin blog.csdn.net/cfk17829572643/article/details/109726912
Ranking