Sun May 25, 2008 3:48 pm
#include<iostream>
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)return y;
return GCD(x,x-y);
}
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.