欧几里得算法
#include<iostream>
using namespace std;
int fun(int a, int b){
if (a >= b){
int r = a%b;
if (r == 0)
return b;
else
fun(b, r);
}
else
fun(b, a);
}
int main()
{
int a, b;
cout << "请输入两个整数" << endl;
cin >> a>>b;
int r = 1;
r = fun(a, b);
cout << a << "和" << b << "的最大公约数是:" << r << endl;
}在这里插入代码片
连续整数检测法
#include<iostream>
using namesp