Base Case of the Pyramid

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:

The base case of the definition.

Base Case of the Pyramid

A recursive definition (or a recursive algorithm) needs two parts:

  1. If the problem is easy, solve it immediately.
  2. If the problem can't be solved immediately, divide it into smaller problems, then:
    • Solve the smaller problems by applying this procedure to each of them.

In terms of pyramidal numbers, this is:

Pyramid(1) = 1
Pyramid(N) = Pyramid(N-1) + Triangle(N)

Oddly, the base case for pyramidal numbers is the peak of the pyramid.

QUESTION 4:

Oh no! This definition uses Triangle(N) without saying anything about it. Is this wrong?