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,…
The closed form is
Hpn=2n(5n−3)
Heptagonal numbers are the fifth in the family of polygonal numbers, following triangular (r=3), square (r=4), pentagonal (r=5), and hexagonal (r=6). The general r-gonal-number formula
Pn(r)=2n[(r−2)n−(r−4)]
specializes to heptagonal at r=7, giving Hpn=n(5n−3)/2.
Sum-of-arithmetic-series form.Hpn is the sum of the first n terms of the arithmetic series 1,6,11,16,21,… with a1=1 and d=5. The common difference is one less than r−2=5 — well, exactly 5, since r=7 gives r−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,… with general term 5k−4:
From the general $r$-gonal formula. Substituting r=7 into Pn(r)=n[(r−2)n−(r−4)]/2:
Hpn=2n(5n−3)
Why the formula is always an integer. Among n and 5n−3, the parity argument: if n is even, n contributes the factor of 2. If n is odd, then 5n is odd and 5n−3 is even. So n(5n−3) is always even.
Given a positive integer m, testing whether it is heptagonal requires two checks.
The test.m is heptagonal if and only if both:
1. 40m+9 is a perfect square, and 2. 3+40m+9 is divisible by 10.
If both hold, the index is
n=103+40m+9
Why both checks are needed. From Hpn=n(5n−3)/2=m, the quadratic 5n2−3n−2m=0 has discriminant 9+40m, which must be a perfect square. The quadratic formula gives n=(3+40m+9)/10, requiring the numerator to be a multiple of 10 for n to be a positive integer.
Derivation of the discriminant 40m + 9. Multiply n(5n−3)=2m by 20 and add 9:
100n2−60n+9=40m+9⟹(10n−3)2=40m+9
So 40m+9 is a perfect square iff 10n−3 is an integer (which it is for integer n), and 40m+9=10n−3, giving n=(40m+9+3)/10.
Example. Is 189 heptagonal? Compute 40⋅189+9=7569=872 — a perfect square. Then (3+87)/10=9, an integer. So 189=Hp9. Verify: 9⋅42/2=189. Confirmed.
Non-example. Is 100 heptagonal? Compute 40⋅100+9=4009. Then 4009≈63.32 — not a perfect square. So 100 is not heptagonal.
Properties and Identities
• Recurrence: Hpn=Hpn−1+(5n−4) with Hp1=1. Each heptagonal adds the next arithmetic-series term. • Difference of consecutive heptagonals: Hpn+1−Hpn=5n+1. Differences are 6, 11, 16, 21, ... • Generating function: ∑n=1∞Hpnxn=(1−x)3x(1+4x). • Asymptotic growth: Hpn∼25n2. Heptagonal numbers grow as the square of the index times 2.5. • Relation to triangulars: Hpn=Tn+3Tn−1 where Tk is the k-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 n.
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 r-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-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.
Centered heptagonal numbers: a central dot surrounded by concentric heptagonal rings. Closed form Cn(7)=(7n2−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+9 being a perfect square is necessary but not sufficient. The divisibility check on 3+40m+9 filters out spurious candidates. Skipping it overcounts heptagonal numbers.
• Misremembering the closed form.Hpn=n(5n−3)/2, not n(5n+3)/2 or n(3n−5)/2. The 5 comes from r−2 with r=7; the 3 comes from r−4.
• Confusing with centered heptagonal numbers. Polygonal Hpn gives 1, 7, 18, 34; centered Cn(7) gives 1, 8, 22, 43. Always check which is intended.
• Mis-substituting in the general formula. For r=7, the formula n[(r−2)n−(r−4)]/2 gives n(5n−3)/2. Common error: writing r−4 as r−2 or r — careful with the substitutions.
• Off-by-one in the index.Hp1=1, not Hp0=0. Some sources start at n=0 with Hp0=0 for consistency with the closed form's behavior at n=0. This explorer uses n=1.
• Membership-test discriminant errors. The correct discriminant for heptagonals is 40m+9. Using 24m+1 (pentagonal) or 8m+1 (triangular) gives wrong results.
Related Sequences and Concepts
Triangular Numbers — Tn=n(n+1)/2. The smallest polygonal sequence; r=3.
Square Numbers — Sn=n2. The r=4 case.
Pentagonal Numbers — Pn=n(3n−1)/2. The r=5 case; features in Euler's pentagonal-number theorem.
Hexagonal Numbers — Hn=n(2n−1). The r=6 case; equals odd-indexed triangulars.
Octagonal Numbers — On=n(3n−2). The r=8 case, after heptagonal.
Centered Heptagonal Numbers — Cn(7)=(7n2−7n+2)/2. A distinct sequence with concentric ring geometry.
Polygonal Numbers — the family of r-gonal numbers. Heptagonal is the r=7 member.
Fermat's Polygonal Number Theorem — every positive integer is a sum of at most rr-gonal numbers. For r=7, the statement says every positive integer is a sum of at most 7 heptagonal numbers.
Arithmetic Series — Hpn=∑k=1n(5k−4). The sum of an arithmetic series with a1=1 and d=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 m, m can be written as a sum of just three heptagonal numbers (a refinement of Fermat's theorem due to Bell and Cauchy).