#include<iostream>
//#include<cstdlib>
using namespace std;
int gcd(int n,int m);
int main()
{
int n,m,result;
cout<<"\nEnter The Two Number To Find The GCD :\n";
cin>>n>>m;
result=gcd(n,m);
cout<<"\nGCD of "<<n<<" and "<<m<<" is "<<result<<endl<<endl;
return 0;
}
int gcd(int n,int m)
{
if((n>=m)&&((n%m)==0))
return(m);
else
gcd(m,(n%m));
}
Output:
Enter The Two Number To Find The GCD :
36
24
GCD of 36 and 24 is 12
need an explanation for this answer? contact us directly to get an explanation for this answer