logo CodeStepByStep logo

recursionMystery11

Language/Type: Java recursion recursive tracing

For each call to the following method, indicate what value is returned:

public static int recursionMystery11(int n) {
    if (n < 0) {
        return -recursionMystery11(-n);
    } else if (n < 10) {
        return n;
    } else {
        return recursionMystery11(n / 10 + n % 10);
    }
}
recursionMystery11(6)
recursionMystery11(17)
recursionMystery11(259)
recursionMystery11(977)
recursionMystery11(-479)

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.