#include<iostream>
using namespace std;
int main()
{
int LCM(int n1,int n2);
int n1, n2;
cout << "输入两个数: ";
cin >> n1 >> n2;
cout<<LCM(n1,n2);
}
int LCM(int n1,int n2)
{
int max;
max = (n1 > n2) ? n1 : n2;
do
{
if (max % n1 == 0 && max % n2 == 0)
{
return max;
break;
}
else
++max;
} while (true);
}
求最小公倍数
最新推荐文章于 2022-11-13 17:09:15 发布