#include <iostream>
using namespace std;
int getMaxCommonDivisor(int a, int b)
{
int t;
while (1)
{
if (a < b)
{
t = a;
a = b;
b = t;
}
if (b == 0)
{
return a;
break;
}
t = b;
b = a%b;
a = t;
}
}
int main()
{
int a, b,c;
cin >> a >> b;
c = getMaxCommonDivisor(a, b);
a = a*b / c;
cout << a;
return 0;
}
1.最小公倍数 = 两数相乘/两数的最大公约数;
leastCommonMultiple(A,B) = A*B/MaximumCommonMultiple(A,B)
2.欧几里得算法求最大公约数,算法流程图见下,来源:
https://blog.csdn.net/qq_42302831/article/details/88587052