Number of Diagonals in a Polygon Calculator

Number of Diagonals in a Polygon Calculator

Popular AI Skill PRO

Enter Calculation

Formula

D=Sides (n)(Sides (n)−3)2D = \frac{{{\text{Sides }(n)}}\left({{\text{Sides }(n)}} - 3\right)}{2}

Example

D=5·(5−3)2=5D = \frac{5 \cdot \left(5 - 3\right)}{2} = 5
Usage stats

Advertisement

Results

Number of Diagonals
5
Number of polygon sides: 5
Number of sides (n) 5
Triangles from one vertex (n − 2) 3

Report an error on this page

What Is a Polygon Diagonal?

A diagonal of a polygon is a straight line segment that connects two non-adjacent vertices (corners). Sides of the polygon are not diagonals because they join neighbouring vertices. This calculator tells you exactly how many diagonals any polygon has, from a triangle up to a thousand-sided shape, using the standard combinatorial formula.

Pentagon with all five diagonals drawn between non-adjacent vertices
A pentagon's diagonals connect non-adjacent vertices, while sides connect adjacent ones.

How to Use the Calculator

Enter the number of sides n of your polygon (which equals the number of vertices) and the calculator returns the total number of diagonals. The number of sides must be 3 or greater, since a triangle is the smallest polygon. Note that a triangle has zero diagonals — all of its vertices are adjacent.

The Formula Explained

The formula is $$D = \frac{n(n - 3)}{2}$$. Each of the n vertices can connect to \(n - 3\) others to form a diagonal: you subtract itself and its two neighbouring vertices. That gives \(n(n - 3)\) endpoints, but every diagonal is counted twice (once from each end), so you divide by 2.

Advertisement
Single vertex of a hexagon connecting to non-adjacent vertices, illustrating n minus 3 diagonals
From each vertex you can draw n−3 diagonals, since the vertex itself and its two neighbors are excluded.

Worked Example

For a pentagon, \(n = 5\). Then $$D = \frac{5 \times (5 - 3)}{2} = \frac{5 \times 2}{2} = 5.$$ A pentagon therefore has 5 diagonals. For a hexagon, \(n = 6\): $$D = \frac{6 \times 3}{2} = 9 \text{ diagonals.}$$ For a square, \(n = 4\): $$D = \frac{4 \times 1}{2} = 2 \text{ diagonals (the two crossing lines).}$$

Diagonals by Number of Sides (Reference Table)

Each vertex of an n-sided polygon connects to \(n-3\) other vertices by a diagonal. It cannot connect to itself or to its two adjacent vertices. Counting every vertex and dividing by 2 (each diagonal has two ends) gives \(D = \frac{n(n-3)}{2}\).

Polygon Sides (n) Diagonals per vertex (n−3) Total diagonals D = n(n−3)/2
Triangle 3 0 0
Quadrilateral 4 1 2
Pentagon 5 2 5
Hexagon 6 3 9
Heptagon 7 4 14
Octagon 8 5 20
Nonagon 9 6 27
Decagon 10 7 35
Hendecagon 11 8 44
Dodecagon 12 9 54
15-gon 15 12 90
20-gon 20 17 170
50-gon 50 47 1175
100-gon 100 97 4850

Example: for \(n = 50\), \(D = \frac{50 \times (50-3)}{2} = \frac{50 \times 47}{2} = \frac{2350}{2} = 1175\).

Advertisement

Key Terms

Polygon
A closed flat shape made of straight line segments that meet end to end and do not cross each other.
Vertex
A corner of a polygon, where two sides meet. A polygon has as many vertices as sides.
Side (edge)
One of the straight line segments forming the boundary of a polygon.
Adjacent vertices
Two vertices joined directly by a side. They are neighbors on the boundary, so the segment between them is a side, not a diagonal.
Diagonal
A line segment joining two non-adjacent vertices of a polygon.
n-gon
A polygon with n sides, for example a 7-gon is a heptagon.
Convex polygon
A polygon in which every interior angle is less than 180° and every diagonal lies inside the shape.
Concave polygon
A polygon with at least one interior angle greater than 180°. Some of its diagonals pass outside the shape. The formula still counts every pair of non-adjacent vertices.
n
The number of sides (and vertices) of the polygon. It must be a whole number of at least 3.
D
The total number of diagonals, calculated as \(D = \frac{n(n-3)}{2}\).

FAQ

Does this work for any polygon? Yes — it works for both convex and concave polygons, since the count of diagonals depends only on the number of vertices, not their positions.

Why does a triangle have no diagonals? All three vertices of a triangle are adjacent to each other, so there are no non-adjacent pairs to connect. The formula confirms this: \(\frac{3 \times (3 - 3)}{2} = 0\).

How many diagonals does a 100-gon have? $$D = \frac{100 \times 97}{2} = 4{,}850 \text{ diagonals.}$$

Last updated:

Most popular in Geometry

View all Geometry calculators