go to previous page   go to home page   go to next page hear noise highlighting

Answer:

It activates Triangle() with a parameter of 2.


Yet Another Activation

Here is the new picture. It shows three activations of Triangle() each with a different parameter.

You may be a bit uneasy about something called Triangle() being active multiple times. But this is perfectly fine. Think of each activation as being a "clone" of Triangle() that has been given its own little task.

three activations

QUESTION 15:

What does the activation Triangle(2) do?

public int Triangle( int N )
{
  if ( N == 1 )
    return 1;
  else
    return N + Triangle( N-1 );
}

go to previous page   go to home page   go to next page