Square Pyramidal Number Calculator

Total balls in the pyramid385
Balls in the bottom layer100
Total without the bottom layer285
Square root of the total19.6
Total as a share of n cubed0.385
How this was calculated
  1. A square pyramid stacks square layers: 10 x 10 = 100 balls on the bottom, shrinking by one ball per side each layer up to a single ball on top.
  2. The square pyramidal number counts them all: P(n) = n(n+1)(2n+1)/6 = 10 x 11 x 21 / 6 = 385. It is also the sum of squares 1^2 + 2^2 + ... + 10^2.
  3. Without the bottom layer the stack holds 285 balls, so the bottom layer alone accounts for 100 of the 385 total.
  4. For large stacks the total approaches n^3 / 3 - already 0.385 of n cubed at n = 10. Cannonball stackers cared: the classic puzzle asks when the total is itself a perfect square, and beyond the trivial stack only n = 24 works, giving 4,900 = 70^2.

The square pyramidal number calculator tells you how many balls or other objects sit in a stack built from square layers, where each layer is a square one ball wider than the one above it. You enter the number of layers, and the calculator returns the total count. A pyramid of 5 layers holds 55 balls. A stack of 10 layers holds 385 balls, and the bottom layer alone is 100 of them. The classic cannonball stack of 24 layers holds 4,900 balls, which is exactly 70 squared; the bottom layer of that stack holds 576 balls, so without it the remaining 23 layers hold 4,324.

The method behind these answers is the accepted standard for this calculation: the total is the sum of squares 1^2 + 2^2 + ... + n^2, computed as n(n+1)(2n+1)/6. That formula counts every ball in every layer exactly once, so it gives the same total as adding the layers by hand, without the arithmetic. For large stacks the total approaches n cubed over 3; at 24 layers it is already 0.354 of n cubed. This page shows the formula, the step-by-step workings, worked examples and sources so you can check each result yourself.

Worked examples

5 layers

(5 layers)

Total balls in the pyramid55
Balls in the bottom layer25
Total without the bottom layer30
Square root of the total7.4
Total as a share of n cubed0.440

10 layers

(10 layers)

Total balls in the pyramid385
Balls in the bottom layer100
Total without the bottom layer285
Square root of the total19.6
Total as a share of n cubed0.385

24 layers

(24 layers)

Total balls in the pyramid4,900
Balls in the bottom layer576
Total without the bottom layer4,324
Square root of the total70 exactly - the total is a perfect square
Total as a share of n cubed0.354

How square pyramidal numbers are calculated

A square pyramidal number counts the objects in a stack of square layers, from a single object on top down to a full square at the base. The cleanest way to see how a square pyramidal number calculator gets its answer is to build the stack one layer at a time. Each layer is a square, so its size is a perfect square: the top layer holds 1, the next holds 4, then 9, then 16, and so on. The total is simply those squares added together — the sum of squares 1^2 + 2^2 + ... + n^2.

For a stack of 5 layers, the layers hold 1, 4, 9, 16 and 25 objects. Adding them gives 55, which matches the known result that a pyramid of 5 layers holds 55 balls. The same total comes from the closed formula n(n+1)(2n+1)/6. Put n = 5 into it and you get 5 x 6 x 11 / 6, which works out to 55. The formula saves you from adding every layer by hand, which matters once the stack gets tall.

Larger stacks show why the formula is useful. A pyramid of 10 layers holds 385 balls, and the bottom layer alone accounts for 100 of them. Push to 24 layers and the total is 4,900 balls. That bottom layer holds 576 balls, so removing it leaves 4,324 — a quick check that the base is a big share of the whole. The 4,900 figure is worth pausing on: it is exactly 70 squared, the famous cannonball result, where a square pyramid of cannonballs 24 layers high contains as many balls as a flat square 70 on a side.

There is also a shortcut for very large stacks. As n grows, the exact total approaches n cubed over 3. At 24 layers the total is already 0.354 of n cubed, so the approximation is close even at modest heights and tightens further as the pyramid grows. This is why a square pyramidal number calculator can return huge totals instantly: it applies n(n+1)(2n+1)/6 directly rather than summing layer after layer.

To use the pattern yourself, start from the base and work upward, or plug the layer count into the formula. Either route gives the same sum of squares, and cross-checking one against the other is a good way to confirm a result.

  • 5 layers: 1 + 4 + 9 + 16 + 25 = 55, also given by 5 x 6 x 11 / 6.
  • 10 layers: 385 balls total, with 100 in the bottom layer alone.
  • 24 layers: 4,900 balls total — exactly 70 squared, the cannonball result.
  • 24 layers, bottom removed: 576 in the base, leaving 4,324.
  • Large stacks: the total approaches n cubed over 3; at 24 layers it is 0.354 of n cubed.
The total is the sum of squares 1^2 + 2^2 + ... + n^2, computed as n(n+1)(2n+1)/6.

The cannonball problem

A square pyramidal number is the total you get when you stack square layers of balls, each layer one row smaller than the one below it, all the way up to a single ball on top. The total is the sum of squares 1^2 + 2^2 + ... + n^2, computed as n(n+1)(2n+1)/6. A small stack shows how quickly the totals grow: a pyramid of 5 layers holds 55 balls, and 10 layers hold 385 balls, of which the bottom layer alone is 100.

Most of these totals are not perfect squares, and that is what makes the cannonball problem interesting. The question is simple to state: for which numbers of layers is the total number of balls itself a perfect square? Only two answers exist. One is the trivial stack, the single ball at the top, where the total is 1. The other is n = 24. A 24-layer stack holds 4,900 balls, and 4,900 is exactly 70 squared. That is the famous cannonball result: a square pyramid of cannonballs that can be rearranged into a single flat square, 70 balls on a side.

The scale of that stack is worth picturing. The bottom layer of the 24-layer stack holds 576 balls, a square 24 by 24. Without that bottom layer, the stack holds 4,324 balls, so the final layer is what completes the perfect square. This is also why a square pyramidal number calculator is handy for checking such claims: enter the number of layers and the formula does the arithmetic, so you can see for yourself that 24 layers give 4,900 while neighboring counts do not.

What took centuries was not finding the answer but proving it was the only one. The result resisted proof for a long time, and showing that no larger stack ever lands on a perfect square again is the hard part. For large stacks the total approaches n cubed over 3, so the totals grow roughly with the cube of the layer count. At 24 layers the total is already 0.354 of n cubed, which gives a sense of how far apart the perfect squares become as stacks get bigger. The single ball and the 24-layer stack of 4,900 are the only cases.

24 layers hold 4,900 balls — exactly 70 squared. The bottom layer alone is 576 of them.

Layer by layer

A square pyramidal number is built the way a real stack of balls is built: one square layer at a time, each layer sitting on the one below it. The bottom layer is the largest square, and every layer above it is the next smaller square. Reading a stack from the bottom up is the clearest way to see why the total grows so quickly, and a square pyramidal number calculator simply does that adding for you.

Start with the smallest example: a pyramid of 5 layers holds 55 balls. The bottom layer of that stack is a 5-by-5 square, so it alone contains 25 balls. Remove it and the remaining four layers hold 30 balls. That is the whole idea of the sequence in miniature — the base does much of the work, but the layers above it still add a substantial amount.

Scale up to 10 layers and the total is 385 balls, of which the bottom layer alone is 100. Here the base is a 10-by-10 square, and it accounts for more than a quarter of the entire stack. The layers above it hold the remaining 285. Notice how the bottom layer's share keeps growing as the pyramid gets taller: each new layer is a larger square than the one before, so the base pulls further ahead of everything stacked on top of it.

The classic demonstration is the 24-layer stack, which holds 4,900 balls — and 4,900 is exactly 70 squared, the famous cannonball result. Its bottom layer holds 576 balls, a 24-by-24 square; without that bottom layer the stack still holds 4,324. So even after removing the single largest layer, thousands of balls remain above it.

Underneath all of this is one formula. The total is the sum of squares 1^2 + 2^2 + ... + n^2, computed as n(n+1)(2n+1)/6. For large stacks the total approaches n cubed over 3: at 24 layers it is already 0.354 of n cubed. That is why the counts climb so steeply — add a layer and you add a whole square, and the squares keep getting bigger.

  • 5 layers: 55 balls total; bottom layer 25; without the bottom layer, 30.
  • 10 layers: 385 balls total; bottom layer 100; without the bottom layer, 285.
  • 24 layers: 4,900 balls total (70 squared); bottom layer 576; without the bottom layer, 4,324.
Every layer is a perfect square, and the bottom one is always the biggest: at 24 layers the base alone holds 576 of the 4,900 balls.

Growth toward n cubed over 3

As a stack of balls grows taller, the total stops looking like a sum of separate layers and starts behaving like a single volume. The square pyramidal number calculator makes that shift easy to see: compare the running total to n cubed, the volume of a cube with the same edge length as the pyramid's base, and watch the ratio settle toward one third. Three data points show the pattern clearly: 0.440 at 5 layers, 0.385 at 10 layers, and 0.354 at 24 layers.

At small sizes the total is a large fraction of n cubed. A pyramid of 5 layers holds 55 balls, and 55 divided by 5 cubed, or 125, is 0.440. Ten layers hold 385 balls, and 385 divided by 1,000 is 0.385. The drop from 0.440 to 0.385 is not a sign that the pyramid is shrinking relative to its base — it is the shape of the approach. Each added layer contributes a square that is small next to the cube that contains the whole stack, so the ratio slides downward toward its limiting value.

The 24-layer case is the cleanest illustration. That stack holds 4,900 balls, and 4,900 is exactly 70 squared — the famous cannonball result. Against 24 cubed, which is 13,824, the total is 0.354 of n cubed. The bottom layer alone accounts for 576 of those balls; without it the stack holds 4,324. Even removing the largest single layer leaves the total close to a third of the cube, because the layers above it still add up to most of the pile.

The reason for the one-third limit is built into the formula. The total is the sum of squares 1^2 + 2^2 + ... + n^2, computed as n(n+1)(2n+1)/6. Multiply out the numerator and the leading term is 2n cubed, while the divisor is 6 — so for large n the total behaves like 2n cubed divided by 6, which is n cubed over 3. The lower-order terms, n squared and n, matter most when n is small, which is why the ratio starts high and drifts down.

Put the three readings side by side and the trend is steady rather than abrupt: 0.440, then 0.385, then 0.354. Nothing in the sequence jumps; each taller stack simply gets a little closer to the limit. Use the square pyramidal number calculator to test other layer counts and watch the share of n cubed move in the same direction every time.

  • 5 layers: 55 balls, or 0.440 of 5 cubed (125).
  • 10 layers: 385 balls, or 0.385 of 10 cubed (1,000); the bottom layer alone is 100.
  • 24 layers: 4,900 balls, or 0.354 of 24 cubed (13,824); the bottom layer alone is 576, and without it the stack holds 4,324.
4,900 balls in a 24-layer stack is exactly 70 squared — the cannonball result — yet it is still only 0.354 of 24 cubed, closing in on one third.

FAQs

How many balls in a 10-layer square pyramid?

A 10-layer square pyramid holds 385 balls in total. The bottom layer alone holds 100 of them, since each layer is a square of balls. The layers shrink as you go up, and adding them all together gives the count of 385.

What is the formula for square pyramidal numbers?

The formula is P(n) = n(n+1)(2n+1)/6. This is the sum of the first n squares, so a square pyramidal number equals 1 squared plus 2 squared and so on up to n squared. Plugging in the number of layers gives the total ball count directly.

Why is 24 layers special?

A 24-layer stack totals 4,900 balls, and 4,900 is a perfect square: 70 squared. This makes it the only non-trivial cannonball stack that forms a perfect square. So 24 layers is a unique case among square pyramids of balls.

How many balls in a 5-layer pyramid?

A 5-layer square pyramid holds 55 balls in total. The count comes from adding the squares of the layer sizes, from the single ball on top down to the bottom layer, which holds 25 balls. The sum of those squares is 55.

How many balls does the bottom layer hold?

The bottom layer holds n squared balls, where n is the number of layers. In the 24-layer stack that is 576 balls, and in the 5-layer stack it is 25 balls. Each layer above holds the next smaller square.

How fast does the total grow?

The total grows toward n cubed divided by 3 as the number of layers increases. At 24 layers the total is 0.354 of n cubed. So the ball count rises quickly, with the cube term dominating once the stack gets tall.

Sources

Related calculators

Triangular Numbers Calculator
The nth triangular number — 1 + 2 + 3 + … + n, the dot pattern that stacks into a triangle — with the neighbouring triangular number and the square the two of them always make.
Pyramid Volume Calculator
Volume of a square pyramid from base side and height — plus face slant height and lateral and total surface area.
Armstrong Number Calculator
Check whether a number is an Armstrong (narcissistic) number: the sum of its digits each raised to the power of the digit count, compared with the number itself.