What is a tetrahedral number?
A tetrahedral number is the total count of identical balls (spheres) when they are stacked into a regular triangular pyramid — a tetrahedron — with n layers. The top layer holds a single ball, and each layer below is a larger triangular arrangement. The n-th tetrahedral number, written \(T_n\), is simply the running total of balls across all n layers. This is pure mathematics and applies identically everywhere.
How to use this calculator
Enter the number of stacked layers n (an integer of 0 or more) and the calculator returns three things: the tetrahedral number \(T_n\) (total balls), the physical stack height \(h_n\) expressed in ball diameters, and the number of balls in the base layer. Use \(n = 0\) for an empty stack (0 balls, 0 height).
The formula explained
Each layer k is itself a triangle holding the k-th triangular number of balls, \(P_k = \dfrac{k(k+1)}{2}\) — so the layers contain 1, 3, 6, 10, ... balls from top down. Summing the first n triangular numbers gives the closed form $$T_n = \dfrac{n(n+1)(n+2)}{6}.$$
For height, close-packed spheres of diameter d have their layer centers separated vertically by \(\sqrt{\tfrac{2}{3}} \approx 0.8165\) diameters. Adding the half-radius at the top and bottom gives the full physical height $$h_n = d\left((n-1)\cdot\sqrt{\tfrac{2}{3}} + 1\right).$$ For a single ball (\(n = 1\)) this correctly returns one diameter.
Worked example (n = 4)
The four layers hold 1, 3, 6 and 10 balls, so $$T_n = 1 + 3 + 6 + 10 = 20.$$ The closed form confirms this: \(\dfrac{4\cdot 5\cdot 6}{6} = 20\) balls. The height is $$h_n = (4-1)\cdot 0.8165 + 1 = 2.4495 + 1 = 3.4495$$ ball diameters.
FAQ
How many balls are in the bottom layer? The base layer holds the n-th triangular number, \(P_n = \dfrac{n(n+1)}{2}\) balls.
What if I want a real length? The height is given in diameters. Multiply \(h_n\) by your actual ball diameter d (in cm, mm, etc.) to get a physical length.
Why does height use sqrt(2/3)? In close packing each upper ball nestles into the dimple formed by three lower balls; that geometry sets the vertical center-to-center step at \(\sqrt{\tfrac{2}{3}} = \dfrac{\sqrt{6}}{3} \approx 0.8165\) of a diameter.