logo CodeStepByStep logo

recursionMystery5

Language/Type: C++ recursion
Author: Marty Stepp (on 2016/06/16)

For each of the calls to the following recursive function below, indicate what value is returned:

int recursionMystery5(int a, int b) {
    if (a < 10 || b < 10) {
        return a + b;
    } else if (a > b) {
        int x = recursionMystery5(a / 2, b / 2);
        int y = recursionMystery5(b, a - b);
        return x + y;
    } else {
        return recursionMystery5(a, b / 2);
    }
}
recursionMystery5(11, 18)
recursionMystery5(26, 12)
recursionMystery5(32, 48)

You must log in before you can solve this problem.


Log In

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.

© Marty Stepp, all rights reserved.