Yeah... I have a headache...
So I have the following code:
public class inc
{
public static void main (String args[])
{
new inc();
}
public inc()
{
System.out.println (addTwo(7));
}
public int addTwo(int n)
{
System.out.println (n);
if (n < 1)
{
return 2;
}
else
{
return addTwo(n-1)+2;
}
}
}
Can anyone PLEASE trace it line by line and tell me what in Alan Turing's name is going on? Like explain the whole recursive part properly...
and please point me to the best website which I can use to understand recursion properly.
Thank you.