logo CodeStepByStep logo

recursion_mystery7

Language/Type: PHP recursion recursion mystery

For each call to the following function, indicate what console output is produced:

function recursion_mystery7($k) {
    if ($k <= 1) {
        print($k);
    } else {
        recursion_mystery7(intval($k / 2));
        print(" = $k");
    }
}
recursion_mystery7(1);
recursion_mystery7(4);
recursion_mystery7(16);
recursion_mystery7(30);
recursion_mystery7(100);

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.