#include <iostream>
using namespace std;
int gcd(int x, int y)
{
if(y==0) // base case
return x;
return gcd(y, x%y); // recursive call
}
int main()
{
int m, n;
cout << "Enter two numbers: ";
cin >> m >> n;
cout << "GCD(" << m << ", " << n << ") = " << gcd(m, n) << endl;
return 0;
}
Comments
Leave a comment