Hi guys,
I just can understand recursions!
This is really putting me down.
I've started quite good, and I perfectly understand the following example:
Code:
void MyRecursion ( int n )
{
if (n<0)
{
printf("%d\n",n);
MyRecursion(n-1);
}
}
or
Code:
void MyRecursion ( int n )
{
if (n<0)
{
MyRecursion(n-1);
printf("%d\n",n);
}
}
But when there is a return value in the recursion I'm lost!
for example:
Code:
int SumAll(int n)
{
if (n>0)
{
return n+SumAll(n-1);
}
else
return 0;
}
I Couldn't find a single article that expalin this issue that an Idiot like me can actually understand.
Anyone can point an article that will explain this issue for me please
Many many thanks