Pick a mode with the four tabs across the top of the card: List first N, List a – b, Test a number or Lookup by index; the ? beside each tab describes it. Learn more about the modes
In List first N, type how many terms to show in Show first and click Update; the cards give the count, the largest term and the sum, and the tiles list every term. Learn more about listing terms
In List a – b, type the From index and the To index and click List range; a red box explains a bad range. Learn more about ranges
In Test a number, type a positive integer in Test number and click Check; a green box names the index, a red box says it is not a heptagonal number. Learn more about the test
The panel on the right explains the current mode and walks through the arithmetic with your own numbers; it changes with every tab and click. Learn more about the panel
The explorer opens on the List first N tab, one of four tabs across the top of the card; the small ? beside each tab shows what the mode does. Type how many terms you want in the Show first box and click Update or press Enter. Three cards answer at once: Showing gives the count, Largest the last term with its index, and Sum the total of the listed terms, which for heptagonal numbers is N(N+1)(5N−2)/6. Under the cards every term is laid out as a tile with its index above its value, so Hp1=1 to HpN can be read in order.
The box accepts 1 to 200: 10 gives Hp10=235 with the sum 880, 30 gives Hp30=2,205 with the sum 22,940, and 300 is capped at 200 terms, ending at Hp200=99,700 with the sum 6,686,600; a single term gives Hp1=1. Large values are printed with thousands separators. A count of 0, a decimal or an empty box is refused with "Enter a positive integer." There is no Reset button: type a new count and click Update again. The panel on the right, List first N, states the rule the tiles come from, and its walkthrough repeats the last term and the sum with your own N. What the terms are is explained in what is a heptagonal number.
Listing a Range of Indexes
DemoThe range tab, a new range, two bad ranges
Step 0 of 4
Click the List a – b tab to list the terms between two positions instead of starting from 1. Type the From index and the To index and click List range or press Enter. The cards give the Countb−a+1, the Smallest term Hpa and the Largest term Hpb, and the tiles below list every term in between with its index. The tab opens with 5 to 15, 11 terms from Hp5=55 to Hp15=540; indexes 10 to 20 give 11 terms from 235 to 970.
Both boxes must hold positive integers, the first no larger than the second, and the range may hold at most 200 terms; otherwise a red box explains: "Enter two positive integer indexes", "From-index must be less than or equal to to-index", or "Range too wide — cap is 200 terms". The panel on the right, List a – b, explains the mode, and its walkthrough names the smallest and largest term of your range. The rule each tile uses is explained in the closed form derivation.
Testing a Number
DemoThe test tab, a non-member, a member, 0
Step 0 of 4
Click the Test a number tab to ask whether a given positive integer is a heptagonal number. Type it in the Test number box and click Check or press Enter. A green box with a tick answers yes and names the index, as for the opening value 189, which is Hp9; a red box with a cross answers no, as for 100, and the walkthrough on the right then shows the two nearest heptagonal numbers, Hp6=81 and Hp7=112. A large value is handled the same way: 3,940 is Hp40.
The box takes positive integers only; 0, a negative number or a decimal is refused with "Enter a positive integer". The test behind the answer is exact: the explorer checks whether 40m+9 is a perfect square whose root is 7 more than a multiple of 10; if it is, the index is (40m+9+3)/10, otherwise the two nearest heptagonal numbers are shown, so no list has to be searched. The panel on the right, Test a number, states this rule, and its walkthrough carries out the arithmetic for your number. The rule itself is explained in the membership test.
Looking Up a Term by Index
DemoThe lookup tab, two indexes, n = 0
Step 0 of 4
Click the Lookup by index tab to compute one term directly. Type the position in the Index n box and click Get term or press Enter. Two cards answer: Index repeats n and Value gives Hpn with its index as a subscript. The tab opens with n=25, which gives Hp25=1,525; n=100 gives 24,850 and n=1000 gives 2,498,500. The box takes positive integers only; 0 is refused with "Enter a positive integer index".
The panel on the right has two parts in every mode. How it works names the rule the mode uses, here Hpn=n(5n−3)/2, and links to the section of this page that explains it; Walkthrough applies the rule to the numbers you typed, so for the lookup it shows the arithmetic with your n filled in. Both change as soon as you switch tabs or click a button. The rule and where it comes from are in the closed form derivation.
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,…
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.
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.
Both families count dots in a heptagon; the simplest figurate family is triangular numbers.
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.
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).