Hexagonal Number Calculator

Number Theory

Hexagonal number P(n)45
Previous term28
Next term66
Sum of the first n terms95
How this was calculated
  1. The hexagonal number for term n is 2n^2 - n. Substituting n = 5 gives the term below.
  2. With 4 as the side coefficient, (4 x 5^2 - 2 x 5) / 2 = 45. Each added side layer contributes 4 x (n - 1) + 1 new dots.
  3. Term 5 of the hexagonal numbers is 45. The term before it is 28 and the term after it is 66.
  4. Adding the first 5 terms gives 95. Each new layer of dots adds a shell around the previous figure, which is why the terms grow quadratically.

The hexagonal numbers are one branch of the figurate numbers - counts of dots that arrange into a regular pattern. The sequence begins 1, 6, 15, 28, 45, 66, 91, 120, 153 and 190. Each term counts the dots in the finished figure at that size, and the calculator above returns the term for any index n together with its neighbours and the running total.

Every figurate family has a closed formula, and for the hexagonal numbers it is 2n^2 - n. That single expression replaces drawing the figure and counting dots one by one, which stops being practical once n grows: the tenth term is already large enough that a hand count would be slow and error-prone.

Enter an index n and the calculator applies the formula in four visible steps: it states the formula, works the arithmetic, reads the term, and adds up the run of terms from the first to the nth. The previous and next terms are shown alongside, which makes it easy to check a value against its neighbours or to extend the sequence by hand.

Worked examples

Fifth hexagonal number

(5)

Hexagonal number P(n)45
Previous term28
Next term66
Sum of the first n terms95

Tenth hexagonal number

(10)

Hexagonal number P(n)190
Previous term153
Next term231
Sum of the first n terms715

Seventh hexagonal number

(7)

Hexagonal number P(n)91
Previous term66
Next term120
Sum of the first n terms252

The formula

The hexagonal number for term n is 2n^2 - n. The expression is quadratic, so the terms grow roughly in proportion to n squared: doubling the index roughly quadruples the term once n is moderately large. Because the formula counts complete figures, n starts at 1, where the figure is a single dot and the term is 1.

A closed formula also settles membership questions in reverse. To test whether a number x belongs to the family, solve the quadratic for n and check whether the answer is a positive whole number; if it is not, x cannot be drawn as one of these figures.

Building the figure layer by layer

A hexagonal figure grows by wrapping a new six-sided layer around the previous one. Each added layer contributes 4(n - 1) + 1 new dots. The hexagonal arrangement is the one bees use: it is the densest way to pack equal circles in a plane, which is why the family shows up in honeycomb and packing problems.

This shell view explains the shape of the formula. The difference between consecutive terms grows by the same amount at each step - the signature of a quadratic sequence - and the calculator's steps show that growth directly through the previous and next terms.

The first terms

The sequence opens 1, 6, 15, 28, 45, 66, 91, 120, 153 and 190. Reading across the first ten terms is the fastest way to develop a feel for the family: the gaps widen steadily, and each gap is larger than the one before by a constant amount.

The running totals grow faster still, roughly with the cube of n, because each new term added to the sum is itself quadratic. The calculator reports the sum of the first n terms next to every value so both growth rates are visible at once.

A worked example

Take n = 5. Substituting into 2n^2 - n gives the term 45. The calculator shows the substitution in its second step rather than jumping to the answer, so the arithmetic can be followed and checked.

The same example gives a running total: the first 5 terms add to 95. If you extend the index by one, the new total must rise by exactly the next term - a quick consistency check that catches most slips.

Neighbours and running totals

Every result comes with the previous term and the next term. The previous term is what the figure held one layer earlier; the next term previews the following layer. Together they bracket the answer and expose the local gap size, which is the shell count for the layer being added.

Running totals answer a different question: not how many dots one figure holds, but how many dots a whole set of figures, one of each size up to n, holds in total. That is the quantity that matters when the figures model stacked or cumulative quantities.

The wider figurate family

Hexagonal numbers have a famous second identity: the hexagonal number for n is exactly the triangular number for 2n - 1. Every hexagonal number is therefore triangular, and the hexagonal numbers are precisely every second triangular number - a fact visible in the sequence, since 1, 15, 45 and 91 all appear among the triangular numbers too.

All of these families share one idea: a geometric arrangement turns a counting problem into algebra. Once a family has a closed formula, its terms, differences and sums can be studied without drawing anything, which is why figurate numbers have been a bridge between geometry and number theory since antiquity.

Where these numbers show up

Figurate numbers appear wherever discrete quantities grow in layers: stacked objects, seating and planting patterns, centred arrangements in materials and tiling, and puzzle and contest problems that ask for counts in a pattern. The same quadratic structure also makes them a standard first example of sequences defined by a polynomial.

In teaching, the family is a gentle route into quadratic sequences: students can draw the first figures, count the shells, and then watch the formula reproduce their counts exactly. The calculator serves the same purpose in reverse - formula first, drawing optional.

Testing membership in reverse

To test a candidate x, solve 2n^2 - n = x, which gives n = (1 + sqrt(1 + 8x)) / 4. The candidate is hexagonal exactly when 1 + 8x is a perfect square and n is a positive whole number. For x = 45: 1 + 8 x 45 = 361 = 19^2, so n = (1 + 19) / 4 = 5 - the fifth hexagonal number. The same test doubles as the triangular test, since every hexagonal number is triangular: 45 is the ninth triangular number as well.

Membership testing matters because figurate numbers are sparse: among the first thousand positive integers only the first few dozen belong to any one family. A quick discriminant check replaces a long scan of the sequence, and the calculator's neighbour display gives a second, independent confirmation - a true member sits exactly between the previous and next terms the calculator prints.

Sums of figurate numbers: the Fermat theorem

In 1638 Fermat claimed that every positive integer is a sum of at most 6 hexagonal numbers - one case of his polygonal number theorem, which assigns each family a budget equal to its number of sides. Gauss proved the triangular case in 1796 and famously marked the day in his diary; Lagrange had settled the square case in 1770; Cauchy proved the full theorem in 1813.

The theorem gives this family a second life beyond dot patterns: the hexagonal numbers are a universal building set, with any integer expressible using at most 6 of them (repetition allowed, and smaller terms doing most of the work). It is a fitting capstone for a family that began as a picture - the geometry of dots ends up governing the additive structure of all integers.

Common mistakes

The most frequent slip is an off-by-one in the index: term numbering starts at n = 1 for a single dot, so the fifth figure uses n = 5, not n = 4. A second slip is mixing the plain and centered families, which share names but count different arrangements and give different sequences.

A third mistake is trusting a term without checking its neighbours. If a claimed term does not sit between the previous and next terms with the expected gap, the arithmetic has gone wrong somewhere - the calculator's four steps make that check immediate.

FAQs

What is the formula?

The hexagonal number for term n is 2n^2 - n.

What is the term at n = 5?

45. The calculator shows the substitution step by step.

What are the first ten terms?

1, 6, 15, 28, 45, 66, 91, 120, 153 and 190.

How fast do the terms grow?

Quadratically: each layer adds a larger shell than the last, and the gap between terms grows by a constant amount each step.

What does the sum of the first n terms mean?

It is the total dot count of one figure of every size from 1 up to n added together - the calculator reports it beside each term.

How can I check a value?

Compare it with its neighbours: the term must exceed the previous term by exactly one shell and fall short of the next term by the next shell.

Does n start at 0 or 1?

At 1 in this calculator, matching the convention that the first figure is a single dot with value 1.

Where are figurate numbers used?

In layered counting problems, stacking and tiling patterns, and as a classic introduction to quadratic sequences.

Is 45 a hexagonal number?

Yes - solving the formula for n gives exactly n = 5, so 45 is the term at that index.

What is the polygonal number theorem?

Fermat's theorem says every positive integer is a sum of at most 6 hexagonal numbers; Cauchy proved the general theorem in 1813.

Sources

Related calculators

Confidence Interval Calculator
The range around a sample mean or a sample proportion at 90%, 95% or 99% confidence, with the standard error and margin of error shown step by step.
Logit Calculator
The logit of a probability: the natural log of the odds, the scale on which logistic regression is linear.
Sphenic Number Calculator
Test whether a number is sphenic - the product of exactly three distinct primes - with its factorization and the next sphenic number.