Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools

Octagonal Numbers Calculator

How to use Octagonal 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 an octagonal 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 octagonal numbers is N(N+1)(2N−1)/2N(N+1)(2N-1)/2. Under the cards every term is laid out as a tile with its index above its value, so O1=1O_1 = 1 to ONO_N can be read in order.

The box accepts 11 to 200200: 1010 gives O10=280O_{10} = 280 with the sum 1,0451,045, 3030 gives O30=2,640O_{30} = 2,640 with the sum 27,43527,435, and 300300 is capped at 200200 terms, ending at O200=119,600O_{200} = 119,600 with the sum 8,019,9008,019,900; a single term gives O1=1O_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 an octagonal 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 OaO_a and the Largest term ObO_b, and the tiles below list every term in between with its index. The tab opens with 55 to 1515, 11 terms from O5=65O_{5} = 65 to O15=645O_{15} = 645; indexes 1010 to 2020 give 11 terms from 280280 to 1,1601,160.

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 an octagonal 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 225225, which is O9O_{9}; a red box with a cross answers no, as for 100100, and the walkthrough on the right then shows the two nearest octagonal numbers, O6=96O_{6} = 96 and O7=133O_{7} = 133. A large value is handled the same way: 4,7204,720 is O40O_{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 3m+13m + 1 is a perfect square whose root is 22 more than a multiple of 33; if it is, the index is (3m+1+1)/3(\sqrt{3m + 1} + 1)/3, otherwise the two nearest octagonal 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 OnO_n with its index as a subscript. The tab opens with n=25n = 25, which gives O25=1,825O_{25} = 1,825; n=100n = 100 gives 29,80029,800 and n=1000n = 1000 gives 2,998,0002,998,000. 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 On=n(3n−2)O_n = n(3n-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 an Octagonal Number?

An octagonal number counts dots in a nested-octagon pattern with a shared vertex. Starting with one dot:

O1=1,O2=8,O3=21,O4=40,O5=65,O6=96,O7=133,…O_1 = 1, \quad O_2 = 8, \quad O_3 = 21, \quad O_4 = 40, \quad O_5 = 65, \quad O_6 = 96, \quad O_7 = 133, \quad \ldots


The closed form is

On=n(3n−2)=3n2−2nO_n = n(3n - 2) = 3n^2 - 2n


Octagonal numbers are the sixth in the family of polygonal numbers, following triangular, square, pentagonal, hexagonal, and heptagonal. 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 octagonal at r=8r = 8, giving On=n(6n−4)/2=n(3n−2)O_n = n(6n - 4)/2 = n(3n - 2).

Sum-of-arithmetic-series form. OnO_n is the sum of the first nn terms of the arithmetic series 1,7,13,19,25,…1, 7, 13, 19, 25, \ldots with a1=1a_1 = 1 and common difference d=6d = 6. The step 6 reflects that r−2=6r - 2 = 6 for r=8r = 8.

For deeper coverage see octagonal 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 and square identities these build on are in properties and properties.

The counting ideas behind these uses start from properties.

The Closed Form Derivation

From the arithmetic-series perspective. Octagonal numbers are sums of the arithmetic series 1,7,13,19,…1, 7, 13, 19, \ldots with general term 6k−56k - 5:

On=∑k=1n(6k−5)=6⋅n(n+1)2−5n=3n2+3n−5n=3n2−2n=n(3n−2)O_n = \sum_{k=1}^{n}(6k - 5) = 6 \cdot \frac{n(n+1)}{2} - 5n = 3n^2 + 3n - 5n = 3n^2 - 2n = n(3n - 2)


From the general rr-gonal formula. Substituting r=8r = 8:

On=n[6n−4]2=n(3n−2)O_n = \frac{n[6n - 4]}{2} = n(3n - 2)


Why the formula is always an integer. On=n(3n−2)O_n = n(3n - 2) is a product of integers, so it is always an integer. No divisibility argument is needed; the closed form has no fractional component.

Connection to triangular numbers. Using Tn=n(n+1)/2T_n = n(n+1)/2:

On=n(3n−2)=3n2−2n=6⋅n(n+1)2−2n−3n=6Tn−5nO_n = n(3n - 2) = 3n^2 - 2n = 6 \cdot \frac{n(n+1)}{2} - 2n - 3n = 6 T_n - 5n


Or more simply: On=3Tn−2n+(correction)O_n = 3 T_n - 2n + (\text{correction}), with the cleanest identity being On=Tn+4Tn−1O_n = T_n + 4 T_{n-1} for n≥2n \geq 2. Expanding triangulars:

On=n(n+1)2+4⋅(n−1)n2=n(n+1)+4n(n−1)2=n(5n−3)2O_n = \frac{n(n+1)}{2} + 4 \cdot \frac{(n-1)n}{2} = \frac{n(n + 1) + 4n(n - 1)}{2} = \frac{n(5n - 3)}{2}


Wait — that gives heptagonal, not octagonal. The correct identity: On=T3n−2−T2n−2O_n = T_{3n - 2} - T_{2n - 2}, which can be verified directly: T3n−2=(3n−2)(3n−1)/2T_{3n-2} = (3n-2)(3n-1)/2 and T2n−2=(2n−2)(2n−1)/2T_{2n-2} = (2n-2)(2n-1)/2; subtracting gives n(3n−2)n(3n - 2) after simplification.

Examples. O1=1O_1 = 1, O2=8O_2 = 8, O3=21O_3 = 21, O4=40O_4 = 40, O10=280O_{10} = 280, O20=1160O_{20} = 1160.

The Membership Test

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

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

1. 3m+13m + 1 is a perfect square, and
2. 1+3m+11 + \sqrt{3m + 1} is divisible by 3.

If both hold, the index is

n=1+3m+13n = \frac{1 + \sqrt{3m + 1}}{3}


Why both checks. From On=n(3n−2)=mO_n = n(3n - 2) = m, the quadratic 3n2−2n−m=03n^2 - 2n - m = 0 has discriminant 4+12m=4(1+3m)4 + 12m = 4(1 + 3m). The square root is 21+3m2\sqrt{1 + 3m}, and the quadratic formula gives

n=2+21+3m6=1+3m+13n = \frac{2 + 2\sqrt{1 + 3m}}{6} = \frac{1 + \sqrt{3m + 1}}{3}


So 3m+13m + 1 must be a perfect square, and the numerator 1+3m+11 + \sqrt{3m + 1} must be a multiple of 3.

Example. Is 225 octagonal? Compute 3⋅225+1=676=2623 \cdot 225 + 1 = 676 = 26^2 — perfect square. Then (1+26)/3=9(1 + 26)/3 = 9, an integer. So 225=O9225 = O_9. Verify: 9⋅25=2259 \cdot 25 = 225. Confirmed.

Triangular but not octagonal. Is 15 octagonal? Compute 3⋅15+1=463 \cdot 15 + 1 = 46. 46≈6.78\sqrt{46} \approx 6.78 — not a perfect square. So 15 is not octagonal, even though it is triangular (T5=15T_5 = 15) and hexagonal (H3=15H_3 = 15).

Non-example. Is 100 octagonal? Compute 3⋅100+1=3013 \cdot 100 + 1 = 301. 301≈17.35\sqrt{301} \approx 17.35 — not a perfect square. So 100 is not octagonal. Nearest are O6=96O_6 = 96 and O7=133O_7 = 133.

Properties and Identities

• Recurrence: On=On−1+(6n−5)O_n = O_{n-1} + (6n - 5) with O1=1O_1 = 1. Each octagonal adds the next arithmetic-series term.
• Difference of consecutive octagonals: On+1−On=6n+1O_{n+1} - O_n = 6n + 1. Differences are 7, 13, 19, 25, ...
• Generating function: ∑n=1∞Onxn=x(1+5x)(1−x)3\sum_{n=1}^{\infty} O_n x^n = \frac{x(1 + 5x)}{(1 - x)^3}.
• Asymptotic growth: On∼3n2O_n \sim 3n^2. Octagonal numbers grow about three times as fast as square numbers.
• Identity in triangulars: On=T3n−2−T2n−2O_n = T_{3n - 2} - T_{2n - 2} for n≥2n \geq 2. Octagonals as a difference of triangulars.
• Sum of first nn octagonals: ∑k=1nOk=n2(n+1)\sum_{k=1}^{n} O_k = n^2(n + 1). A cleaner closed form than for some other polygonals.
• Last-digit pattern: octagonal numbers in base 10 end only in 0, 1, 3, 5, 6, or 8. Numbers ending in other digits cannot be octagonal.

Common Applications

Like heptagonal numbers, octagonal numbers have fewer celebrated identities than the lower-degree polygonals, but they appear in several contexts.

• Fermat's polygonal number theorem. Every positive integer is a sum of at most 8 octagonal numbers. The r=8r = 8 case of the general theorem.
• Polygonal completeness. When the polygonal family is studied systematically, octagonal is one of the canonical members; figurate-number tables routinely include it.
• Lattice problems. Some 2D counting problems on octagonal regions involve octagonal-number boundaries.
• Combinatorial identities. Identities relating octagonals to triangulars, squares, and pentagonals form parts of papers on figurate-number arithmetic.
• Number-theoretic curiosities. Octagonal numbers that are also squares, triangulars, or pentagonals are individually studied; the intersections are sparse.
• Educational use. Octagonal numbers are commonly used to illustrate the polygonal-number paradigm beyond the well-known triangular, square, and pentagonal cases.

Octagonal vs Centered Octagonal Numbers

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

Octagonal numbers (this page): nested octagons sharing one vertex. Closed form On=n(3n−2)O_n = n(3n - 2). Sequence: 1, 8, 21, 40, 65, 96, ...

Centered octagonal numbers: a central dot surrounded by concentric octagonal rings. Closed form Cn(8)=4n2−4n+1=(2n−1)2C_n^{(8)} = 4n^2 - 4n + 1 = (2n - 1)^2. Sequence: 1, 9, 25, 49, 81, 121, ...

Notably, centered octagonal numbers are exactly the odd perfect squares: Cn(8)=(2n−1)2C_n^{(8)} = (2n - 1)^2. This unexpected identity makes the centered version more famous in some contexts.

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

Both families count dots in an octagon; the simplest figurate family is triangular numbers.

Common Mistakes

• Forgetting the divisibility-by-3 check. 3m+13m + 1 being a perfect square is necessary but not sufficient. The divisibility check on 1+3m+11 + \sqrt{3m + 1} filters out spurious candidates.

• Misremembering the closed form. On=n(3n−2)O_n = n(3n - 2), not n(3n+2)n(3n + 2) or n(2n−3)n(2n - 3). The 3 comes from (r−2)/2=3(r - 2)/2 = 3 for r=8r = 8; the 2 comes from (r−4)/2=2(r - 4)/2 = 2.

• Confusing with centered octagonal numbers. Polygonal OnO_n gives 1, 8, 21, 40; centered Cn(8)C_n^{(8)} gives 1, 9, 25, 49 (the odd squares). Very different sequences.

• Misapplying the discriminant. The correct discriminant for octagonals is 3m+13m + 1. Using 8m+18m + 1 (triangular), 24m+124m + 1 (pentagonal), or 40m+940m + 9 (heptagonal) gives wrong results.

• Off-by-one in arithmetic series. The series is 1,7,13,19,…1, 7, 13, 19, \ldots with general term 6k−56k - 5 (where kk starts at 1). Writing 6k+16k + 1 or 6k−16k - 1 gives different sequences.

• Confusing polygonal index with side count. OnO_n is the nn-th octagonal number, not the count of dots in an octagon with side nn (though they happen to coincide for the polygonal definition; the indexing can be subtle).

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