不用辗转相除法,那你就直接暴力遍历呗
公约数要从大往小遍历,公倍数要从小往大遍历
c++17引入了最大公约数和最小公倍数的算法
#include <iostream>
#include <numeric>
using namespace std;
int main()
{
// 最小公倍数
cout << std::lcm(25, 20) << std::endl;
// 最大公约数
cout << std::gcd(60, 24) << std::endl;
return 0;
}