public class Temp{
static int add(int m,int n){
if(m==0)
return n+1;
else if(n==0)
return add(m-1,1);
else
return add(m-1,add(m,n-1));
}
public static void main(String[] a){
System.out.println(add(3,3));
}
}
I am not able to understand what this function is achieving. The output for (2,2) is 7 and for (3,3) is 61. I understand that the value of n decreases then value of m and then the base case is reached but how can I get the output without running the code for a given input?