Diagonals Formula n(n-3)/2 with Worked Examples

#Formula
TL;DR
The diagonals formula counts the diagonals of an nn-sided polygon as n(n−3)2\frac{n(n-3)}{2}. This article gives the derivation, five worked examples, and the halving error.
BT
Bhanzu TeamLast updated on November 7, 20266 min read

Key Points

  • The diagonals formula is D=n(n−3)2D = \frac{n(n-3)}{2}, giving the number of diagonals in a polygon with nn sides.

  • The OEIS records that n(n−3)/2n(n-3)/2 for n≥3n \geq 3 is the number of diagonals of an nn-gon.

  • Each vertex joins to n−3n-3 others, excluding itself and its two neighbours, which is where the n−3n-3 comes from.

  • The division by 2 is needed because counting from every vertex names each diagonal twice, once from each end.

  • A triangle has zero diagonals, which the formula returns correctly since 3(3−3)/2=03(3-3)/2 = 0.

What Is the Diagonals Formula?

The diagonals formula counts how many diagonals a polygon has from its number of sides:

D=n(n−3)2D = \frac{n(n-3)}{2}

A diagonal is a line segment joining two non-adjacent vertices. The On-Line Encyclopedia of Integer Sequences records that n(n−3)/2n(n-3)/2 for n≥3n \geq 3 gives the number of diagonals of an nn-gon.

This article covers only that count. For the length of a diagonal in a specific shape, see the diagonals page, which deals with diagonal segments and their measurements rather than how many exist.

Why the Formula Is n Times n Minus 3, Halved

Pick any vertex of an nn-sided polygon. It cannot join to itself, and joining to either of its two neighbours produces a side rather than a diagonal, so it has n−3n-3 possible diagonals.

Doing that from every vertex gives n(n−3)n(n-3) segments. But each diagonal has two endpoints and gets counted once from each, so the true total is half that figure.

A second route reaches the same place. The number of segments joining any two of the nn vertices is n(n−1)2\frac{n(n-1)}{2}, and removing the nn sides leaves n(n−1)2−n=n(n−3)2\frac{n(n-1)}{2} - n = \frac{n(n-3)}{2}.

Variable Key

Symbol

Meaning

Unit or type

Notes

nn

number of sides

integer, at least 3

also the number of vertices

n−3n-3

diagonals from one vertex

count

excludes itself and two neighbours

n(n−3)n(n-3)

endpoint count

count

each diagonal counted twice

DD

number of diagonals

whole number

n(n−3)2\frac{n(n-3)}{2}

Examples of the Diagonals Formula

Example 1

How many diagonals does a hexagon have?

D=6(6−3)2=182=9D = \frac{6(6-3)}{2} = \frac{18}{2} = 9

Final answer: 9 diagonals

Example 2

How many diagonals does an octagon have, counting from every vertex without halving?

Each of the 8 vertices reaches 8−3=58-3 = 5 others, so counting from every vertex gives

8×5=408 \times 5 = 40

That 40 is too large, and the reason is visible on a drawing. The diagonal from vertex A to vertex D gets counted once when working from A and again when working from D, so every diagonal appears twice in the total.

Halving corrects it:

D=8(8−3)2=402=20D = \frac{8(8-3)}{2} = \frac{40}{2} = 20

Final answer: 20 diagonals

Example 3

How many diagonals does a triangle have?

D=3(3−3)2=3×02=0D = \frac{3(3-3)}{2} = \frac{3 \times 0}{2} = 0

Final answer: 0

Every pair of vertices in a triangle is adjacent, so no diagonal exists. The formula returns this correctly rather than breaking down.

Example 4

A polygon has 35 diagonals. How many sides does it have?

Set the formula equal to 35 and solve:

n(n−3)2=35  ⟹  n2−3n−70=0  ⟹  (n−10)(n+7)=0\frac{n(n-3)}{2} = 35 \implies n^2 - 3n - 70 = 0 \implies (n-10)(n+7) = 0

Final answer: n=10n = 10, a decagon. The root n=−7n = -7 is discarded as a side count cannot be negative.

Example 5

How many diagonals does a 20-sided polygon have?

D=20(20−3)2=20×172=170D = \frac{20(20-3)}{2} = \frac{20 \times 17}{2} = 170

Final answer: 170 diagonals

The count grows roughly with the square of the number of sides, which is why diagonals multiply so quickly on larger polygons.

Don't Confuse the Diagonal Count With These Three

Quantity

Formula

What it gives

Number of diagonals

n(n−3)2\frac{n(n-3)}{2}

how many diagonals exist

All vertex pairs

n(n−1)2\frac{n(n-1)}{2}

diagonals plus sides

Diagonals from one vertex

n−3n-3

the count at a single corner

Length of a diagonal

varies by shape

a measurement, not a count

The last row is a different question entirely. A square's diagonal length is a2a\sqrt{2}, and that has nothing to do with how many diagonals a square has, which is 2.

Where Intuition Breaks on the Diagonals Formula

Mistake 1: Forgetting to halve

Where it slips in: Counting n−3n-3 from each of nn vertices is the natural first move, and the result looks like a finished total.

Don't do this: D=n(n−3)D = n(n-3)

The correct way: D=n(n−3)2D = \frac{n(n-3)}{2}. Each diagonal has two ends and is counted once from each.

Students who draw a pentagon and count its diagonals by hand, getting 5, then test both candidate formulas against that number, never forget the halving. Verifying a counting formula on the smallest case you can draw is the quickest structural check there is.

Mistake 2: Using n minus 2 instead of n minus 3

Where it slips in: Excluding the vertex itself and one neighbour gives n−2n-2, and the second neighbour is easy to overlook.

Don't do this: D=n(n−2)2D = \frac{n(n-2)}{2}

The correct way: Three vertices are unavailable from any starting vertex: itself and both neighbours. On a hexagon that leaves 3 diagonals per vertex, not 4.

Mistake 3: Applying the formula to a non-polygon or to a shape with fewer than 3 sides

Where it slips in: The formula is algebraic, so it returns values for n=1n = 1 and n=2n = 2.

Don't do this: Compute DD for n=2n = 2 and report 1.

The correct way: The formula holds for n≥3n \geq 3, as the OEIS entry states. Below three sides there is no polygon, so the output is meaningless rather than merely wrong.

Bottom Line

  • The diagonals formula is D=n(n−3)2D = \frac{n(n-3)}{2} for a polygon with nn sides.

  • The n−3n-3 comes from excluding the vertex itself and its two neighbours.

  • The halving removes the double count, since each diagonal is reached from both of its ends.

  • The formula holds from n=3n = 3 upwards, correctly returning zero diagonals for a triangle.

  • To work through polygon geometry with a teacher, explore a geometry tutor or math tuition.

Where to Go From Here

Find the number of diagonals in a pentagon and a dodecagon. Then work out how many sides a polygon has if it holds 54 diagonals.

Want a live Bhanzu trainer to walk through more geometry problems? Book a free demo class.

Read More

Was this article helpful?

Your feedback helps us write better content

Frequently Asked Questions

What is the diagonals formula?
D=n(n−3)2D = \frac{n(n-3)}{2}, where nn is the number of sides of the polygon.
Why does the diagonals formula subtract 3?
Because each vertex cannot join to itself or to either of its two neighbours, leaving n−3n-3 vertices it can reach by a diagonal.
Why is the diagonals formula divided by 2?
Because counting from every vertex names each diagonal twice, once from each endpoint.
How many diagonals does a square have?
Two. Substituting n=4n = 4 gives 4×12=2\frac{4 \times 1}{2} = 2.
✍️ Written By
BT
Bhanzu Team
Content Creator and Editor
Bhanzu’s editorial team, known as Team Bhanzu, is made up of experienced educators, curriculum experts, content strategists, and fact-checkers dedicated to making math simple and engaging for learners worldwide. Every article and resource is carefully researched, thoughtfully structured, and rigorously reviewed to ensure accuracy, clarity, and real-world relevance. We understand that building strong math foundations can raise questions for students and parents alike. That’s why Team Bhanzu focuses on delivering practical insights, concept-driven explanations, and trustworthy guidance-empowering learners to develop confidence, speed, and a lifelong love for mathematics.
Related Articles
Book a FREE Demo ClassBook Now →