logo CodeStepByStep logo

RecursionMystery9

Language/Type: C# recursion

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

public static int RecursionMystery9(int x, int y)
{
    if (x < 0)
    {
        return -RecursionMystery9(-x, y);
    }
    else if (y < 0)
    {
        return -RecursionMystery9(x, -y);
    }
    else if (x == 0 && y == 0)
    {
        return 0;
    }
    else
    {
        return 100 * RecursionMystery9(x / 10, y / 10) + 10 * (x % 10) + y % 10;
    }
}
RecursionMystery9(12, 49);
RecursionMystery9(73, -8);
RecursionMystery9(-248, -3795);

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.