#include <iostream>
using namespace std;
int main(void)
{
int a,b;cin>>a>>b;
while(a % b != 0){//辗转相除法求最大公约数
int t = a % b;
a = b;
b = t;
}
cout<<b<<endl;
//最小公倍数 = 两数相乘除以最大公约数
return 0;
}
其证明可在百度百科上找到
#include <iostream>
using namespace std;
int main(void)
{
int a,b;cin>>a>>b;
while(a % b != 0){//辗转相除法求最大公约数
int t = a % b;
a = b;
b = t;
}
cout<<b<<endl;
//最小公倍数 = 两数相乘除以最大公约数
return 0;
}
其证明可在百度百科上找到