this is my gcd prog..
#include<iostre am>
using namespace std;
int GCD(int ,int );
void main()
{
int x,y;
cout<<"Plz enter the two numbers : ";
cin>>x>>y;
cout<<"The GCD("<<x<<","<< y<<") = " << GCD(x,y)<<endl;
}
int GCD(int x,int y)
{
if(y>x)return GCD(y,x);
if(x==y)return x;
if(x%y==0)retur n y;
return GCD(x,x-y);
}
if i enter numbers like 13 17..the prog gets stuck..so now how to solve that error????
#include<iostre am>
using namespace std;
int GCD(int ,int );
void main()
{
int x,y;
cout<<"Plz enter the two numbers : ";
cin>>x>>y;
cout<<"The GCD("<<x<<","<< y<<") = " << GCD(x,y)<<endl;
}
int GCD(int x,int y)
{
if(y>x)return GCD(y,x);
if(x==y)return x;
if(x%y==0)retur n y;
return GCD(x,x-y);
}
if i enter numbers like 13 17..the prog gets stuck..so now how to solve that error????
Comment