Consider the following recursive function. int function (int x, int y) { if (y…

Coal India Management Trainee CBT 2019Modified — slightly modified from the official paper; see the solution

Consider the following recursive function.

int function (int x, int y) {
   if (y <= 0) return x;
   return function (y, x % y);
}

The above recursive function computes ______.

  1. A.

    GCD of x and y

  2. B.

    yˣ

  3. C.

    x × y

  4. D.

    LCM of x and y

Attempted by 1236 students.

Sign up free to check your answer

Sign up free

Explore the full course: Isro

Loading lesson…