我正在创建一个程序来使用欧几里得方法计算两个数字的 gcd,但我得到了一个浮点异常错误。我应该怎么办?
/*
Euclidian Greatest Common Divisor Key Lemma
if gcd(a,b) = gcd(a',b) = gcd(b,a') Where a' = a % b
Proof
let a = a' + bq ... (1) , where q is some number
if d is the gcd then b is divisible by d and also a is divisible by d
then from the equation(1) we can see that a' is also divisible by d.
*/
#include<iostream>
using namespace std;
int euclidgcd(int a, int b)
{
int c = a % b;
if(b == 0)
{
return a;
}
else
{
return euclidgcd(b, c);
}
}
int main()
{
int a,b;
std::cout << "give a and b where a > b" << '\n';
std::cin >> a >> b;
int d = euclidgcd(a, b);
return 0;
}