Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools

Heptagonal Numbers Calculator






What is a Heptagonal Number?

A heptagonal number counts dots in a nested-heptagon pattern with a shared vertex. Starting with a single dot:

Hp1=1,Hp2=7,Hp3=18,Hp4=34,Hp5=55,Hp6=81,\mathrm{Hp}_1 = 1, \quad \mathrm{Hp}_2 = 7, \quad \mathrm{Hp}_3 = 18, \quad \mathrm{Hp}_4 = 34, \quad \mathrm{Hp}_5 = 55, \quad \mathrm{Hp}_6 = 81, \quad \ldots


The closed form is

Hpn=n(5n3)2\mathrm{Hp}_n = \frac{n(5n - 3)}{2}


Heptagonal numbers are the fifth in the family of polygonal numbers, following triangular (r=3r = 3), square (r=4r = 4), pentagonal (r=5r = 5), and hexagonal (r=6r = 6). The general rr-gonal-number formula

Pn(r)=n[(r2)n(r4)]2P_n^{(r)} = \frac{n[(r - 2)n - (r - 4)]}{2}


specializes to heptagonal at r=7r = 7, giving Hpn=n(5n3)/2\mathrm{Hp}_n = n(5n - 3)/2.

Sum-of-arithmetic-series form. Hpn\mathrm{Hp}_n is the sum of the first nn terms of the arithmetic series 1,6,11,16,21,1, 6, 11, 16, 21, \ldots with a1=1a_1 = 1 and d=5d = 5. The common difference is one less than r2=5r - 2 = 5 — well, exactly 5, since r=7r = 7 gives r2=5r - 2 = 5.

For deeper coverage see heptagonal number, polygonal numbers, and figurate numbers.

The Closed Form Derivation

From the arithmetic-series perspective. Heptagonal numbers are sums of the arithmetic series 1,6,11,16,1, 6, 11, 16, \ldots with general term 5k45k - 4:

Hpn=k=1n(5k4)=5n(n+1)24n=5n2+5n8n2=5n23n2=n(5n3)2\mathrm{Hp}_n = \sum_{k=1}^{n}(5k - 4) = 5 \cdot \frac{n(n+1)}{2} - 4n = \frac{5n^2 + 5n - 8n}{2} = \frac{5n^2 - 3n}{2} = \frac{n(5n - 3)}{2}


From the general $r$-gonal formula. Substituting r=7r = 7 into Pn(r)=n[(r2)n(r4)]/2P_n^{(r)} = n[(r-2)n - (r-4)]/2:

Hpn=n(5n3)2\mathrm{Hp}_n = \frac{n(5n - 3)}{2}


Why the formula is always an integer. Among nn and 5n35n - 3, the parity argument: if nn is even, nn contributes the factor of 2. If nn is odd, then 5n5n is odd and 5n35n - 3 is even. So n(5n3)n(5n - 3) is always even.

Examples. Hp1=12/2=1\mathrm{Hp}_1 = 1 \cdot 2/2 = 1. Hp2=27/2=7\mathrm{Hp}_2 = 2 \cdot 7/2 = 7. Hp3=312/2=18\mathrm{Hp}_3 = 3 \cdot 12/2 = 18. Hp4=417/2=34\mathrm{Hp}_4 = 4 \cdot 17/2 = 34. Hp5=522/2=55\mathrm{Hp}_5 = 5 \cdot 22/2 = 55. Hp10=1047/2=235\mathrm{Hp}_{10} = 10 \cdot 47/2 = 235.

The Membership Test

Given a positive integer mm, testing whether it is heptagonal requires two checks.

The test. mm is heptagonal if and only if both:

1. 40m+940m + 9 is a perfect square, and
2. 3+40m+93 + \sqrt{40m + 9} is divisible by 10.

If both hold, the index is

n=3+40m+910n = \frac{3 + \sqrt{40m + 9}}{10}


Why both checks are needed. From Hpn=n(5n3)/2=m\mathrm{Hp}_n = n(5n - 3)/2 = m, the quadratic 5n23n2m=05n^2 - 3n - 2m = 0 has discriminant 9+40m9 + 40m, which must be a perfect square. The quadratic formula gives n=(3+40m+9)/10n = (3 + \sqrt{40m + 9})/10, requiring the numerator to be a multiple of 10 for nn to be a positive integer.

Derivation of the discriminant 40m + 9. Multiply n(5n3)=2mn(5n - 3) = 2m by 20 and add 9:

100n260n+9=40m+9    (10n3)2=40m+9100 n^2 - 60n + 9 = 40m + 9 \implies (10n - 3)^2 = 40m + 9


So 40m+940m + 9 is a perfect square iff 10n310n - 3 is an integer (which it is for integer nn), and 40m+9=10n3\sqrt{40m + 9} = 10n - 3, giving n=(40m+9+3)/10n = (\sqrt{40m + 9} + 3)/10.

Example. Is 189 heptagonal? Compute 40189+9=7569=87240 \cdot 189 + 9 = 7569 = 87^2 — a perfect square. Then (3+87)/10=9(3 + 87)/10 = 9, an integer. So 189=Hp9189 = \mathrm{Hp}_9. Verify: 942/2=1899 \cdot 42/2 = 189. Confirmed.

Non-example. Is 100 heptagonal? Compute 40100+9=400940 \cdot 100 + 9 = 4009. Then 400963.32\sqrt{4009} \approx 63.32 — not a perfect square. So 100 is not heptagonal.

Properties and Identities

Recurrence: Hpn=Hpn1+(5n4)\mathrm{Hp}_n = \mathrm{Hp}_{n-1} + (5n - 4) with Hp1=1\mathrm{Hp}_1 = 1. Each heptagonal adds the next arithmetic-series term.
Difference of consecutive heptagonals: Hpn+1Hpn=5n+1\mathrm{Hp}_{n+1} - \mathrm{Hp}_n = 5n + 1. Differences are 6, 11, 16, 21, ...
Generating function: n=1Hpnxn=x(1+4x)(1x)3\sum_{n=1}^{\infty} \mathrm{Hp}_n x^n = \frac{x(1 + 4x)}{(1 - x)^3}.
Asymptotic growth: Hpn5n22\mathrm{Hp}_n \sim \frac{5n^2}{2}. Heptagonal numbers grow as the square of the index times 2.5.
Relation to triangulars: Hpn=Tn+3Tn1\mathrm{Hp}_n = T_n + 3 T_{n-1} where TkT_k is the kk-th triangular number — a curious identity expressing heptagonals in terms of triangulars.
Sum of first $n$ heptagonals: there is no clean closed-form sum identity (unlike triangulars summing to tetrahedrals); the sum is a polynomial of degree 3 in nn.

Common Applications

Heptagonal numbers have fewer celebrated identities than triangular, pentagonal, or hexagonal numbers, but they appear in several contexts.

Polygonal-number completeness. When studying the family of rr-gonal numbers systematically, heptagonal is the natural fifth member. Many theorems about polygonal numbers (like Fermat's polygonal number theorem) include heptagonal as a case.
Fermat's polygonal number theorem. Every positive integer is a sum of at most 7 heptagonal numbers. The general statement: every positive integer is a sum of at most rr rr-gonal numbers.
Combinatorial counts. Some lattice-counting problems on heptagonal regions involve heptagonal-number boundaries.
Heptagonal-number arrangements. The dots-in-a-heptagon visual is used in puzzles and educational materials.
Number-theoretic curiosities. Heptagonal numbers appear in lists of figurate numbers used to illustrate the structure of polygonal numbers.
Sums and differences. Identities relating heptagonals to other figurate numbers form parts of papers on figurate-number arithmetic.

Heptagonal vs Centered Heptagonal Numbers

As with hexagonal numbers, there is a distinct sequence called the centered heptagonal numbers, which should not be confused with the polygonal heptagonal numbers covered here.

Heptagonal numbers (this page): nested heptagons sharing one vertex. Closed form Hpn=n(5n3)/2\mathrm{Hp}_n = n(5n - 3)/2. Sequence: 1, 7, 18, 34, 55, 81, 112, ...

Centered heptagonal numbers: a central dot surrounded by concentric heptagonal rings. Closed form Cn(7)=(7n27n+2)/2C_n^{(7)} = (7n^2 - 7n + 2)/2. Sequence: 1, 8, 22, 43, 71, 106, ...

The two sequences are different both numerically and geometrically. The "centered" version has more visual symmetry but is mathematically a separate object.

When literature refers to "heptagonal numbers" without qualification, it almost always means the polygonal sequence covered here. Centered heptagonals require the "centered" qualifier.

Common Mistakes

Forgetting the divisibility-by-10 check. 40m+940m + 9 being a perfect square is necessary but not sufficient. The divisibility check on 3+40m+93 + \sqrt{40m + 9} filters out spurious candidates. Skipping it overcounts heptagonal numbers.

Misremembering the closed form. Hpn=n(5n3)/2\mathrm{Hp}_n = n(5n - 3)/2, not n(5n+3)/2n(5n + 3)/2 or n(3n5)/2n(3n - 5)/2. The 5 comes from r2r - 2 with r=7r = 7; the 3 comes from r4r - 4.

Confusing with centered heptagonal numbers. Polygonal Hpn\mathrm{Hp}_n gives 1, 7, 18, 34; centered Cn(7)C_n^{(7)} gives 1, 8, 22, 43. Always check which is intended.

Mis-substituting in the general formula. For r=7r = 7, the formula n[(r2)n(r4)]/2n[(r-2)n - (r-4)]/2 gives n(5n3)/2n(5n - 3)/2. Common error: writing r4r - 4 as r2r - 2 or rr — careful with the substitutions.

Off-by-one in the index. Hp1=1\mathrm{Hp}_1 = 1, not Hp0=0\mathrm{Hp}_0 = 0. Some sources start at n=0n = 0 with Hp0=0\mathrm{Hp}_0 = 0 for consistency with the closed form's behavior at n=0n = 0. This explorer uses n=1n = 1.

Membership-test discriminant errors. The correct discriminant for heptagonals is 40m+940m + 9. Using 24m+124m + 1 (pentagonal) or 8m+18m + 1 (triangular) gives wrong results.

Related Sequences and Concepts

Triangular NumbersTn=n(n+1)/2T_n = n(n+1)/2. The smallest polygonal sequence; r=3r = 3.

Square NumbersSn=n2S_n = n^2. The r=4r = 4 case.

Pentagonal NumbersPn=n(3n1)/2P_n = n(3n-1)/2. The r=5r = 5 case; features in Euler's pentagonal-number theorem.

Hexagonal NumbersHn=n(2n1)H_n = n(2n-1). The r=6r = 6 case; equals odd-indexed triangulars.

Octagonal NumbersOn=n(3n2)O_n = n(3n - 2). The r=8r = 8 case, after heptagonal.

Centered Heptagonal NumbersCn(7)=(7n27n+2)/2C_n^{(7)} = (7n^2 - 7n + 2)/2. A distinct sequence with concentric ring geometry.

Polygonal Numbers — the family of rr-gonal numbers. Heptagonal is the r=7r = 7 member.

Fermat's Polygonal Number Theorem — every positive integer is a sum of at most rr rr-gonal numbers. For r=7r = 7, the statement says every positive integer is a sum of at most 7 heptagonal numbers.

Arithmetic SeriesHpn=k=1n(5k4)\mathrm{Hp}_n = \sum_{k=1}^{n}(5k - 4). The sum of an arithmetic series with a1=1a_1 = 1 and d=5d = 5.

Figurate Numbers — the umbrella family covering all polygonal, pyramidal, and higher-dimensional analogs.

Generalized Polygonal Numbers — extensions where the index ranges over all integers (positive, zero, negative). The pentagonal case features in Euler's theorem; the heptagonal generalization is less prominent.

Sum of Three Heptagonals — for sufficiently large mm, mm can be written as a sum of just three heptagonal numbers (a refinement of Fermat's theorem due to Bell and Cauchy).