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 an octagonal 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 octagonal numbers is N(N+1)(2N−1)/2. Under the cards every term is laid out as a tile with its index above its value, so O1=1 to ON can be read in order.
The box accepts 1 to 200: 10 gives O10=280 with the sum 1,045, 30 gives O30=2,640 with the sum 27,435, and 300 is capped at 200 terms, ending at O200=119,600 with the sum 8,019,900; a single term gives O1=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 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 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 Oa and the Largest term Ob, and the tiles below list every term in between with its index. The tab opens with 5 to 15, 11 terms from O5=65 to O15=645; indexes 10 to 20 give 11 terms from 280 to 1,160.
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 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 225, which is O9; a red box with a cross answers no, as for 100, and the walkthrough on the right then shows the two nearest octagonal numbers, O6=96 and O7=133. A large value is handled the same way: 4,720 is O40.
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 3m+1 is a perfect square whose root is 2 more than a multiple of 3; if it is, the index is (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 n and Value gives On with its index as a subscript. The tab opens with n=25, which gives O25=1,825; n=100 gives 29,800 and n=1000 gives 2,998,000. 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 On=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 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 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,…
The closed form is
On=n(3n−2)=3n2−2n
Octagonal numbers are the sixth in the family of polygonal numbers, following triangular, square, pentagonal, hexagonal, and heptagonal. The general r-gonal-number formula
Pn(r)=2n[(r−2)n−(r−4)]
specializes to octagonal at r=8, giving On=n(6n−4)/2=n(3n−2).
Sum-of-arithmetic-series form.On is the sum of the first n terms of the arithmetic series 1,7,13,19,25,… with a1=1 and common difference d=6. The step 6 reflects that r−2=6 for r=8.
For deeper coverage see octagonal number, polygonal numbers, and figurate numbers.
From the general r-gonal formula. Substituting r=8:
On=2n[6n−4]=n(3n−2)
Why the formula is always an integer.On=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)/2:
On=n(3n−2)=3n2−2n=6⋅2n(n+1)−2n−3n=6Tn−5n
Or more simply: On=3Tn−2n+(correction), with the cleanest identity being On=Tn+4Tn−1 for n≥2. Expanding triangulars:
Wait — that gives heptagonal, not octagonal. The correct identity: On=T3n−2−T2n−2, which can be verified directly: T3n−2=(3n−2)(3n−1)/2 and T2n−2=(2n−2)(2n−1)/2; subtracting gives n(3n−2) after simplification.
Given a positive integer m, testing whether it is octagonal requires two checks.
The test.m is octagonal if and only if both:
1. 3m+1 is a perfect square, and 2. 1+3m+1 is divisible by 3.
If both hold, the index is
n=31+3m+1
Why both checks. From On=n(3n−2)=m, the quadratic 3n2−2n−m=0 has discriminant 4+12m=4(1+3m). The square root is 21+3m, and the quadratic formula gives
n=62+21+3m=31+3m+1
So 3m+1 must be a perfect square, and the numerator 1+3m+1 must be a multiple of 3.
Example. Is 225 octagonal? Compute 3⋅225+1=676=262 — perfect square. Then (1+26)/3=9, an integer. So 225=O9. Verify: 9⋅25=225. Confirmed.
Triangular but not octagonal. Is 15 octagonal? Compute 3⋅15+1=46. 46≈6.78 — not a perfect square. So 15 is not octagonal, even though it is triangular (T5=15) and hexagonal (H3=15).
Non-example. Is 100 octagonal? Compute 3⋅100+1=301. 301≈17.35 — not a perfect square. So 100 is not octagonal. Nearest are O6=96 and O7=133.
Properties and Identities
• Recurrence: On=On−1+(6n−5) with O1=1. Each octagonal adds the next arithmetic-series term. • Difference of consecutive octagonals: On+1−On=6n+1. Differences are 7, 13, 19, 25, ... • Generating function: ∑n=1∞Onxn=(1−x)3x(1+5x). • Asymptotic growth: On∼3n2. Octagonal numbers grow about three times as fast as square numbers. • Identity in triangulars: On=T3n−2−T2n−2 for n≥2. Octagonals as a difference of triangulars. • Sum of first n octagonals: ∑k=1nOk=n2(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=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). 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)2. Sequence: 1, 9, 25, 49, 81, 121, ...
Notably, centered octagonal numbers are exactly the odd perfect squares: Cn(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+1 being a perfect square is necessary but not sufficient. The divisibility check on 1+3m+1 filters out spurious candidates.
• Misremembering the closed form.On=n(3n−2), not n(3n+2) or n(2n−3). The 3 comes from (r−2)/2=3 for r=8; the 2 comes from (r−4)/2=2.
• Confusing with centered octagonal numbers. Polygonal On gives 1, 8, 21, 40; centered Cn(8) gives 1, 9, 25, 49 (the odd squares). Very different sequences.
• Misapplying the discriminant. The correct discriminant for octagonals is 3m+1. Using 8m+1 (triangular), 24m+1 (pentagonal), or 40m+9 (heptagonal) gives wrong results.
• Off-by-one in arithmetic series. The series is 1,7,13,19,… with general term 6k−5 (where k starts at 1). Writing 6k+1 or 6k−1 gives different sequences.
• Confusing polygonal index with side count.On is the n-th octagonal number, not the count of dots in an octagon with side n (though they happen to coincide for the polygonal definition; the indexing can be subtle).
Heptagonal Numbers — Hpn=n(5n−3)/2. The r=7 polygonal sequence.
Centered Octagonal Numbers — (2n−1)2 — the odd squares. A distinct sequence with concentric-ring geometry.
Polygonal Numbers — the general r-gonal family. Octagonal is the r=8 member.
Fermat's Polygonal Number Theorem — every positive integer is a sum of at most 8 octagonal numbers. The general statement: every positive integer is a sum of at most rr-gonal numbers, proved by Cauchy.
Arithmetic Series — On=∑k=1n(6k−5). The sum of an arithmetic series with a1=1 and d=6.
Figurate Numbers — the umbrella family.
Star Number — a related sequence (6n2−6n+1) sometimes confused with octagonal but distinct; gives 1, 13, 37, 73, 121, ...
Octagonal Pyramidal Numbers — the 3D analog: n(n+1)(2n−1)/2 wait, actually the formula is more involved. They count dots in an octagonal pyramid.
Generalized Polygonal Numbers — extension where indexes can be negative; less famous for octagonals than for pentagonals.