递归法求最大公约数,最小公倍数
//递归法求最大公约数
#include<iostream>
using namespace std;
//递归函数
int greatestCommonDivisor(int a,int b)
{
return (a % b == 0) ? b : greatestCommonDivisor(b, a % b);
}
int main()
{
int a, b;
cin >> a >> b;
int greatestComDiv = greatestCommonDivisor(a, b);
int leastComMul = a * b / greatestComDiv;
cout << "最大公约数=" << greatestComDiv << endl;
cout << "最小公倍数=" << leastComMul << endl;
return 0;
}