logo CodeStepByStep logo

recursion_mystery13

Language/Type: PHP recursion recursion mystery

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

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

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.