Connect via MCP →

Enter Calculation

Formula

Advertisement

Results

Number of Diagonals
9
for a 6-sided polygon
Sides (n) 6
Formula n(n − 3) / 2

What Is the Number of Diagonals of a Polygon?

A diagonal is a straight line segment that connects two non-adjacent vertices of a polygon. Sides connect adjacent vertices, so they are not counted as diagonals. This calculator tells you exactly how many diagonals any polygon has, based only on its number of sides (n).

Pentagon with all five diagonals drawn between non-adjacent vertices
A diagonal connects two non-adjacent vertices; a pentagon has five of them.

How to Use the Calculator

Enter the number of sides of your polygon — for example, 3 for a triangle, 4 for a quadrilateral, 5 for a pentagon, and so on. The calculator instantly returns the total number of diagonals. The number of sides must be at least 3, since fewer than three sides cannot form a closed polygon.

The Formula Explained

The number of diagonals is given by $$D = \frac{n(n - 3)}{2}$$. Each of the \(n\) vertices can connect to \(n - 3\) others by a diagonal (you exclude itself and its two neighbours). That gives \(n(n - 3)\) connections, but each diagonal is counted twice — once from each endpoint — so we divide by 2.

One vertex of a hexagon with diagonals fanning out to non-adjacent vertices
From each vertex you can draw a diagonal to n−3 other vertices, which explains the formula.

Worked Example

Consider a hexagon, which has \(n = 6\) sides. Plugging into the formula: $$D = \frac{6 \times (6 - 3)}{2} = \frac{6 \times 3}{2} = \frac{18}{2} = 9$$ So a hexagon has 9 diagonals. For a pentagon (\(n = 5\)): \(D = \frac{5 \times 2}{2} = 5\) diagonals.

FAQ

How many diagonals does a triangle have? Zero. With \(n = 3\), \(D = \frac{3 \times 0}{2} = 0\), because every pair of vertices is already connected by a side.

Does the shape have to be regular? No. The formula depends only on the number of sides, so it works for any simple (non-self-intersecting) polygon, regular or irregular.

How many diagonals does a square have? A square (\(n = 4\)) has \(D = \frac{4 \times 1}{2} = 2\) diagonals.

Last updated: