正整数A,B的最小公倍数是指能被A和B整除的最小的正整数值,设计一个算法,求输入A和B的最小公倍数。
#include<iostream>
using namespace std;
int main()
{
//最小公倍数=两数之积/最大公约数;
int A,B,p;
cin>>A>>B;
p=A*B;
if(A<B) swap(A,B)
while(B!=0)
{
int temp;
temp=A%B;
A=B;
B=temp;
}
cout<<p/A<<endl;
return 0;
}