The gcd(m, n) can also be defined recursively as follows:

• If m % n is 0, gcd (m, n) is n.
• Otherwise, gcd(m, n) is gcd(n, m % n).

Write a recursive function to find the GCD. Write a test program that computes gcd(24, 16) and gcd(255, 25).


```
#include
using namespace std;

int gcd(int m, int n) {
if (m % n == 0)
return n;
else
return gcd(n, m % n);
}

int main()
{
// Enter the first number
cout << "Enter the first number: ";
int m;
cin >> m;

// Enter the first number
cout << "Enter the second number: ";
int n;
cin >> n;

cout << "The GCD of " << m << " and " << n << " is " <<
gcd(m, n) << endl;

return 0;
}
```

Computer Science & Information Technology

You might also like to view...

The ____ command shows disk use information for all files in a specified directory and its subdirectories.

A. du B. free C. top D. df

Computer Science & Information Technology

Anti-aliasing is especially effective when using large font sizes.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

The SharePoint Newsfeed contains ________ default views

A) four B) five C) six D) seven

Computer Science & Information Technology

To remove workbook protection, click the Unprotect Workbook button in the _____ group on the Review tab.

A. Format B. Changes C. Sheet D. Options

Computer Science & Information Technology