Following is a very famous algorithm whose recursive version is
significantly easier to express than the iterative one. It was originally
proposed by the Greek mathematician Euclid! For the following
subproblems, provide the final value returned by the function.
int ea(int x, int y)
{
if (y == 0)
return x;
else
return ea(y, x % y);
}
a. ea(12, 15)
b. ea(6, 10)
c. ea(110, 24)
d. What does this function calculate? Consider how you might
construct an iterative version to calculate the same thing.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here