public static int t(int n) {
if (n < 3) return n;
return t(n-1) + t(n-2) + t(n-3);
}
// Call: System.out.println(t(5));What is printed?
- A
7
- Bcheck_circle
11
- C
5
- D
13
Explanation
Base: t(0)=0, t(1)=1, t(2)=2. t(3)=t(2)+t(1)+t(0)=3. t(4)=t(3)+t(2)+t(1)=6. t(5)=t(4)+t(3)+t(2)=6+3+2=11.