Support Me...........

Please support me by giving donation

contact: aswinavofficial@gmail.com


Total Pageviews

Monday, September 1, 2014

C++ program to find greatesy common divisor

// Program to find GCD of two numbers #include using namespace std; int gcd(int m, int n, int d=-1) { if (d==-1) d = m>n ? n : m; if (m%d==0 && n%d==0) return d; else return gcd(m, n, d-1); } int main() { int m, n; cout << "Enter first number: "; cin >> m; cout << "Enter second number: "; cin >> n; cout << "GCD is " << gcd(m,n); return 0; }

No comments: