Another
Triangle()
is activated with a parameter of 3.
The statement:
return N + Triangle( N-1 );
must get a value for Triangle(N-1) before the addition can be done.
So the first activation of Triangle() causes a
second activation of Triangle(), this time with
a parameter of 3.
Here is how this is pictured:
Look at the code again. Think about the latest activation.
What does the activation Triangle(3)
int Triangle( int N )
{
if ( N == 1 )
return 1;
else
return N + Triangle( N-1 );
}