Yet Another Activation

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.

Answer:

It activates Triangle() with a parameter of 2.

Yet Another Activation

Here is the new picture. 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 13:

What does the activation Triangle(2) do?

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