0
Why this problem print 2?
public class Program { public static void main(String[] args){ System.out.println(tri(3)); } static int tri(int n){ return n==0 ? 0 : n ==1 ? 1 : tri(n-1) + tri(n-2); } }
1 Respuesta
+ 2
n = 3
return tri(2)+tri(1)
tri(2)
return tri(1)+ tri(0)
tri(1)
return 1
tri(0)
return 0
So 1+1+0