logo CodeStepByStep logo

recursion_mystery17

Language/Type: PHP recursion recursion mystery

For each call to the following recursive function, write the output that would be produced, as it would appear on the console.

function recursion_mystery17($x) {
    if ($x < 10) {
        print($x);
    } else {
        $y = $x % 10;
        print($y);
        recursion_mystery17(intval($x / 10));
        print($y);
    }
}
recursion_mystery17(7);
recursion_mystery17(38);
recursion_mystery17(194);
recursion_mystery17(782);
recursion_mystery17(3842);

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.