logo CodeStepByStep logo

Mystery1

Language/Type: C# recursion recursive tracing

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

public static void Mystery1(int k)
{
    if (k <= 1)
    {
        Console.Write(k);
    }
    else
    {
        Mystery1(k / 2);
        Console.Write(" = " + k);
    }
}
Mystery1(1);
Mystery1(4);
Mystery1(16);
Mystery1(30);
Mystery1(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.