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...

When using an Office 2013 application, the title bar displays the current file and which application is being used

Indicate whether the statement is true or false

Computer Science & Information Technology

You can quickly choose a layout and styles for a selected chart from the Ribbon. Click the ____ tab under Chart Tools on the Ribbon. In the Chart Layouts group, click the chart layout you want to use.

A. Format B. Edit C. Styles D. Design

Computer Science & Information Technology