// p04_07.cpp: Recursive and nonrecursive computation
//             of the greatest common divisor (gcd).
#include <iostream>
using namespace std;

int gcd(int x, int y)     // Recursive
{  return y == 0 ? x : gcd(y, x % y);
}

int gcd1(int x, int y)    // Nonrecursive
{  int t;
   while (y > 0)
   {  t = x;
      x = y;
      y = t % y;
   }
   return x;
}           

int main()
{  int a, b;
   cout << "Enter two integers a and b (not both zero):\n";
   cin >> a >> b;
   a = abs(a);
   b = abs(b);
   if (a + b == 0) 
      cout << "a = b = 0 is not allowed.\n"; 
   else
   {  cout << "gcd (a, b) = " << gcd(a, b) << endl;
      cout << "gcd1(a, b) = " << gcd1(a, b) << endl;
   }
   return 0;
}


