بزرگ ترین مقسوم علیه دو عدد با استفاده از تابع بازگشتی
#include<iostream>
#include<conio.h>
using namespace std;
unsigned gcd(unsigned int, unsigned int);
int main()
{
unsigned x, y, gcD1v;
cout << "Enter two integers: ";
cin >> x >> y;
gcD1v = gcd(x, y);
cout << "Greatest common divisor of " << x << " and "
<< y << " is " << gcD1v << endl;
getch();
return 0;
}
//
unsigned gcd(unsigned xMatch, unsigned yMatch)
{
return yMatch == 0 ? xMatch : gcd(yMatch, xMatch % yMatch);
}