i am having trouble understanding this example. I cant figure out what actually happens after a certain point.
Here is the code, the result is supposed to be 4.
The recursion function can be written in a less compact fashion this way:
int recursion(int i)
{
if(i>1)
{
int j;
j = i - recursion(i/2); // note here that the function recall itself
// note also that as i is integer the function
// will be invoked with i/2 rounded to the lower int value
return j;
}
else
{
return 3;
}
}
hope this helps...