I have the following code that sum all the numbers from 1 to N.
I don't understand how it works...Code:#include <stdio.h>
int Sum(int n)
{
if (n>0)
{
return n+Sum(n-1);
}
else
return 0;
}
int main(void)
{
printf("%d\n",Sum(4));
return 0;
}
Can someone please explain this code step by step.
Many Thanks!!!