Hexagonal Pyramidal Number Calculator

Count a stack whose layers are hexagonal numbers, from n times n plus one times four n minus one over six.

Math and PercentUpdated 2026-11-182 min read
Hexagonal Pyramidal Number Calculator
A whole number from 0 to 100,000.
Hexagonal pyramidal number
...
Previous term...
Growth from previous...

What it does

Hexagonal pyramidal numbers count a stack whose layers are hexagonal numbers. The nth term is the sum of the first n hexagonal numbers. The sequence begins 0, 1, 7, 22, 50 and 95, and it is sometimes called the greengrocer numbers because of the shape of a pile of fruit.

Like the other polygonal pyramids, this family is built by stacking flat figurate shapes. Replacing the hexagonal layer by a pentagonal or square layer gives the neighbouring families, while keeping the same style of cubic formula.

The closed form is n times n plus one times four n minus one, divided by six. It comes from summing k times two k minus one from one to n. The numerator is always divisible by six, and the tool checks this before returning a result.

This page evaluates the formula with exact integer arithmetic and reports the previous term and ratio beside the answer. It gives counts only, not a drawing of the stack.

The layer limit is one hundred thousand, which keeps the printed value around sixteen digits.

How to use

  1. Enter the number of layers n from 0 to 100,000.
  2. Read the hexagonal pyramidal number in the main result box.
  3. Check the previous term and growth beside it.
  4. The default n = 8 reproduces the worked example.
  5. Try n = 5 to confirm the value 95.
  6. Compare with pentagonal pyramidal numbers at the same count.

Formula

P(n) = n(n + 1)(4n - 1) / 6
n
The number of hexagonal layers.
P(n)
The total number of points in the stack.

The formula is obtained by summing k times two k minus one for k from one to n, which is the definition of the hexagonal numbers. The result simplifies to n times n plus one times four n minus one over six. The value at n = 0 is zero.

Worked example

Example: eight layers

The page opens with n = 8.

  1. Compute n plus one: 9.
  2. Compute four n minus one: 32 - 1 = 31.
  3. Multiply the three factors: 8 x 9 x 31 = 2232.
  4. Divide by six: 2232 / 6 = 372.
  5. The tool reports 372, previous term 252, and growth 1.48x.
  6. Check the previous value: 7 x 8 x 27 / 6 = 252.

Reference table

Hexagonal pyramidal numbers
nP(n)PreviousGrowth
00n/an/a
110n/a
2717.00x
450222.27x
595501.90x
83722521.48x

Limits

  • Layer counts above 100,000 are rejected to keep the output readable.
  • The growth column is rounded to two decimals.
  • The tool provides counts, not drawings.
  • Only the standard hexagonal pyramid family is used.

Common mistakes

  • Using four n minus two instead of four n minus one.
  • Forgetting the division by six.
  • Using the hexagonal number formula rather than the pyramidal sum.
  • Expecting quadratic growth from a cubic formula.
  • Rounding the division rather than checking exactness.

Try it yourself

Quick checks. Answers sit tucked under each question.

What is P(8)?

P(8) = 8 x 9 x 31 / 6 = 372.

What is P(5)?

P(5) = 5 x 6 x 19 / 6 = 95.

What is P(2)?

P(2) = 2 x 3 x 7 / 6 = 7.

Questions

Why greengrocer numbers?

The name refers to stacks of goods arranged with hexagonal layers.

How do the layers work?

Each layer is an ordinary hexagonal number, summed from one to n.

Is the division always exact?

Yes, and the tool checks it before returning the result.

What is the growth rate?

Cubic, since three linear factors appear in the formula.

Are values exact?

Yes. Integer arithmetic is used.

What layer count is accepted?

Zero through 100,000.

Sources

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.