/**********************************************
Revisiting the GCD.  The way Euclid would've 
phrased his GCD algorithm would be more like this:
If A and B (okay, he was greek, so it probably 
would've been alpha and beta ...) are two 
integers with A >= B >= 0 then the GCD of 
A and B is given by:

* if B = 0 then the GCD is A

* if B > 0 then the GCD is the same as 
  the GCD of B and A%B.

Using this phrasing of the algorithm, implement 
the GCD as a recursive function.
 **********************************************/
#include <iostream>
using namespace std;

int GCD(int,int);

int main()
{
  // Get int's
  int x, y, z;
  cout << "Enter two int's: ";
  cin >> x >> y;

  // Compute and print GCD
  z = GCD(x,y);
  cout << "GCD is " << z << endl;

  return 0;
}

int GCD(int A, int B)
{
  int g;

  if (B == 0)
    g = A;          // BASE CASE
  else
    g = GCD(B,A%B); // RECURSIVE CASE

  return g;
}