Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
hard Solved by 7 students

Tracing Mutual Recursive Methods

< Prev
Next >

What is the output of the following program?

public class MutualRecursion {
    public static int a(int n) {
        if (n <= 0) return 0;
        return n - b(n-1);
    }
    public static int b(int n) {
        if (n <= 0) return 0;
        return n - a(n-1);
    }
    public static void main(String[] args) {
        System.out.println(a(3));
    }
}
A

2

B

3

C

0

D

1

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question
Mark for review

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#1kaisuki11 0m 00s 100
#2parth.taur22722 2m 30s 50
#3lsj0803092211 1m 15s 25
#4richa.tuli12 2m 33s -63
#5bommasam00011 2m 56s -76
#6chunxiangxu.cxu01 8m 10s -500
#7liuwilliam07241012 2h 20m -8,359
Items per page:
10
1 – 7 of 7
No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|FAQ