Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools

Heptagonal Numbers Calculator

How to use Heptagonal Numbers Calculator
  1. 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
  2. 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
  3. 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
  4. 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
  5. In Lookup by index, type the position in Index n and click Get term. Learn more about lookups
  6. 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





Listing the First N Terms

DemoTen terms, thirty terms, the cap, one term
Step 0 of 4
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)/6N(N+1)(5N-2)/6. Under the cards every term is laid out as a tile with its index above its value, so Hp1=1Hp_1 = 1 to HpNHp_N can be read in order.

The box accepts 11 to 200200: 1010 gives Hp10=235Hp_{10} = 235 with the sum 880880, 3030 gives Hp30=2,205Hp_{30} = 2,205 with the sum 22,94022,940, and 300300 is capped at 200200 terms, ending at Hp200=99,700Hp_{200} = 99,700 with the sum 6,686,6006,686,600; a single term gives Hp1=1Hp_1 = 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 NN. 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 11. Type the From index and the To index and click List range or press Enter. The cards give the Count b−a+1b - a + 1, the Smallest term HpaHp_a and the Largest term HpbHp_b, and the tiles below list every term in between with its index. The tab opens with 55 to 1515, 11 terms from Hp5=55Hp_{5} = 55 to Hp15=540Hp_{15} = 540; indexes 1010 to 2020 give 11 terms from 235235 to 970970.

Both boxes must hold positive integers, the first no larger than the second, and the range may hold at most 200200 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 189189, which is Hp9Hp_{9}; a red box with a cross answers no, as for 100100, and the walkthrough on the right then shows the two nearest heptagonal numbers, Hp6=81Hp_{6} = 81 and Hp7=112Hp_{7} = 112. A large value is handled the same way: 3,9403,940 is Hp40Hp_{40}.

The box takes positive integers only; 00, 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+940m + 9 is a perfect square whose root is 77 more than a multiple of 1010; if it is, the index is (40m+9+3)/10(\sqrt{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 nn and Value gives HpnHp_n with its index as a subscript. The tab opens with n=25n = 25, which gives Hp25=1,525Hp_{25} = 1,525; n=100n = 100 gives 24,85024,850 and n=1000n = 1000 gives 2,498,5002,498,500. The box takes positive integers only; 00 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)/2Hp_n = 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 nn 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,…\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(5n−3)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[(r−2)n−(r−4)]2P_n^{(r)} = \frac{n[(r - 2)n - (r - 4)]}{2}


specializes to heptagonal at r=7r = 7, giving Hpn=n(5n−3)/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 r−2=5r - 2 = 5 — well, exactly 5, since r=7r = 7 gives r−2=5r - 2 = 5.

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

Figurate numbers are introduced through their simplest case in triangular numbers; the general idea of an explicit formula is explicit and recursive definitions.

The same pairing argument for the triangular case is written out in derivation of the closed form.

The test it generalises is the triangular one in properties.

The triangular identities these build on are in properties.

The counting ideas behind these uses start from properties.

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 5k−45k - 4:

Hpn=∑k=1n(5k−4)=5⋅n(n+1)2−4n=5n2+5n−8n2=5n2−3n2=n(5n−3)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 rr-gonal formula. Substituting r=7r = 7 into Pn(r)=n[(r−2)n−(r−4)]/2P_n^{(r)} = n[(r-2)n - (r-4)]/2:

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


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

Examples. Hp1=1⋅2/2=1\mathrm{Hp}_1 = 1 \cdot 2/2 = 1. Hp2=2⋅7/2=7\mathrm{Hp}_2 = 2 \cdot 7/2 = 7. Hp3=3⋅12/2=18\mathrm{Hp}_3 = 3 \cdot 12/2 = 18. Hp4=4⋅17/2=34\mathrm{Hp}_4 = 4 \cdot 17/2 = 34. Hp5=5⋅22/2=55\mathrm{Hp}_5 = 5 \cdot 22/2 = 55. Hp10=10⋅47/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(5n−3)/2=m\mathrm{Hp}_n = n(5n - 3)/2 = m, the quadratic 5n2−3n−2m=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(5n−3)=2mn(5n - 3) = 2m by 20 and add 9:

100n2−60n+9=40m+9  ⟹  (10n−3)2=40m+9100 n^2 - 60n + 9 = 40m + 9 \implies (10n - 3)^2 = 40m + 9


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

Example. Is 189 heptagonal? Compute 40⋅189+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: 9⋅42/2=1899 \cdot 42/2 = 189. Confirmed.

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

Properties and Identities

• Recurrence: Hpn=Hpn−1+(5n−4)\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+1−Hpn=5n+1\mathrm{Hp}_{n+1} - \mathrm{Hp}_n = 5n + 1. Differences are 6, 11, 16, 21, ...
• Generating function: ∑n=1∞Hpnxn=x(1+4x)(1−x)3\sum_{n=1}^{\infty} \mathrm{Hp}_n x^n = \frac{x(1 + 4x)}{(1 - x)^3}.
• Asymptotic growth: Hpn∼5n22\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+3Tn−1\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 nn 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(5n−3)/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)=(7n2−7n+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.

Both families count dots in a heptagon; the simplest figurate family is triangular numbers.

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(5n−3)/2\mathrm{Hp}_n = n(5n - 3)/2, not n(5n+3)/2n(5n + 3)/2 or n(3n−5)/2n(3n - 5)/2. The 5 comes from r−2r - 2 with r=7r = 7; the 3 comes from r−4r - 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[(r−2)n−(r−4)]/2n[(r-2)n - (r-4)]/2 gives n(5n−3)/2n(5n - 3)/2. Common error: writing r−4r - 4 as r−2r - 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.

Index conventions and the two ways of defining a sequence are explained in definition and notation and explicit and recursive definitions.