Triangle Numbers

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:

10 + Pins in Row 5 = 15

Triangle Numbers

The total number of pins in a triangular arrangement is called a triangle number. The total number of pins in a triangular arrangement of 5 rows is 5 plus the number of pins in 4 rows. Let us call this number Triangle(5).

Here is a chart that gives the first seven triangle numbers. But it seems not to be complete. Luckily you can fill it in. Click on the figure at right to see the various arrangements.

Ten Pins
Triangle Numbers
RowsTriangle(Rows) Formula
1 base case
2 2 + Triangle(1)
3 3 + Triangle(2)
4 4 + Triangle(3)
5 5 + Triangle(4)
6 6 + Triangle(5)
7 7 + Triangle(6)

QUESTION 3:

Fill in the chart.