It activates Triangle()
Finally we are at the base case.
When Triangle()
if
statement causes the
value 1
to be immediately returned.
The chain of activations is called an activation chain. The picture on this page shows the activation chain when it has reached the base case.
int Triangle( int N ) { if ( N == 1 ) return 1; else return N + Triangle( N-1 ); }
Now look again at the activation where N = 2
Triangle(1)
:
2 | int Triangle( int N ) { if ( N == 1 ) return 1; else return N + Triangle( N-1 ); | ------+------- | | 2 1 }
What value does this activation return to its caller?