/********************************************** 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 using namespace std; int GCD(int,int); int main5435() { // 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) { if (B == 0) { return A; } // recursive step return GCD(B, A%B); return 0; }