Example 1
- n: 4
2
How many diagonals does a quadrilateral have? 2.
Enter an integer number of vertices n (n ≥ 3). The number of diagonals of a convex n-gon is D = n(n − 3)/2. A quadrilateral (n = 4) gives 2. A pentagon (n = 5) gives 5. A hexagon (n = 6) gives 9. A triangle (n = 3) gives 0. The calculator returns the count of diagonals, not their lengths or the angle sum.
Enter an integer n ≥ 3.
The calculator counts how many diagonals there are, not how long they are. n must be an integer at least 3. For n = 3 the result is 0; a fractional n is rejected.
A diagonal of a convex polygon is a segment joining two vertices that are not neighbors on the boundary. Sides are not diagonals. The count of such segments in an n-gon is a classic school-geometry and discrete-combinatorics result: D = n(n − 3)/2 for an integer n ≥ 3. The same formula appears in standard discrete-mathematics texts when counting edges of graphs and in geometry references on polygon diagonals.
Vertex derivation: from a fixed vertex you can connect to n − 1 others. Two of them are neighbors (sides), so n − 3 diagonals remain. Across n vertices you get n(n − 3) “ends.” Each diagonal has two ends, so you divide by 2 to obtain D.
Combinatorial derivation: the number of all vertex pairs is C(n,2) = n(n − 1)/2. Of those, n pairs are the polygon sides. The rest are diagonals: D = C(n,2) − n = n(n − 3)/2. Equivalently: edges of the complete graph Kₙ minus the n cycle edges. For n = 6: C(6,2) = 15, sides = 6, D = 9.
The calculator uses the single number n that you enter. The result D is a non-negative integer. Worked values: triangle n = 3 → 0; quadrilateral n = 4 → 2; pentagon n = 5 → 5; hexagon n = 6 → 9; heptagon n = 7 → 14; octagon n = 8 → 20; decagon n = 10 → 35. Fractional n and n < 3 are rejected — the algebraic expression for n = 2 equals −1, but that does not describe a polygon.
This calculator does not compute diagonal lengths, areas, or angle sums. The interior-angle sum (n − 2)×180° lives on a related page and uses the same n for a different result. The diagram draws a regular n-gon with diagonals for n up to 16; beyond that the count still comes from D = n(n − 3)/2.
In school and contest problems the formula gives a quick diagonal count and supports tournament-style counting (matches = edges of Kₙ). In graphics and CAD, a fan triangulation of a convex n-gon uses n − 3 diagonals from one vertex (n − 2 triangles). Here the result is only the total number of diagonals.
D = n(n − 3) / 2, where n ∈ ℕ, n ≥ 3.
Equivalently: D = C(n,2) − n = n(n − 1)/2 − n. The symbol n is the number of vertices (and sides) of a convex polygon. The symbol D is the diagonal count. C(n,2) is the number of vertex pairs, i.e. the edges of the complete graph Kₙ.
Mathematical model: number of diagonals of a convex n-gon (standard school / combinatorial formula), matching polygon-diagonal theorems and discrete-mathematics counting (Rosen and graph textbooks).
The number of diagonals of a convex (or simple) polygon with n vertices, n ≥ 3, is the number of segments joining two non-adjacent vertices. The combinatorial formula is D = n(n − 3)/2. Each vertex connects by diagonals to n − 3 others (all except itself and its two neighbours); summing n(n − 3) counts each diagonal twice, hence the division by 2.
For a triangle (n = 3) one obtains D = 0 — no diagonals. For a quadrilateral D = 2, for a pentagon D = 5, for a hexagon D = 9. MathWorld (Polygon Diagonal) gives the same formula. In Euclidean geometry, diagonals of a convex polygon lie inside the figure; with concavity some may go outside, but the vertex-pair counting formula remains the same. The calculator reports that combinatorial count for integer n ≥ 3.
Counting diagonals belongs to elementary geometric combinatorics and appears in classical school exercises and in Euclid’s Elements in the context of dissecting polygons into triangles. The number of ways to choose 2 vertices among n is C(n, 2) = n(n − 1)/2; among them n are sides, so the number of diagonals is C(n, 2) − n = n(n − 3)/2.
Conceptually D is a nonnegative integer. The calculator takes n as an integer ≥ 3; non-integers or n < 3 do not describe a polygon in this sense. The formula does not depend on side lengths or on regularity — only on the number of vertices and adjacency on the cycle. Side lengths and angles affect geometry, not this discrete count.
Domain: n ∈ ℤ, n ≥ 3. Result: D = n(n − 3)/2 ∈ {0, 1, 2, …}. Sequence: 0, 2, 5, 9, 14, 20, … (for n = 3, 4, 5, 6, 7, 8, …). Increment: D(n+1) − D(n) = n − 1 — adding a vertex adds n − 1 new diagonals after the cycle is updated.
Equivalent forms: D = C(n, 2) − n; D = (n² − 3n)/2. For a regular polygon the same D diagonals can be drawn in the circumscribed circle; interior intersections are a separate problem (number of crossing points), which this formula does not solve.
Triangulation: a convex n-gon splits into n − 2 triangles via n − 3 non-crossing diagonals from one vertex — a different count from D (the total number of all diagonals). Full D also includes diagonals that cross inside.
Step 1. A polygon has n vertices joined in a cycle: each has exactly two neighbours along the boundary.
Step 2. From a fixed vertex one can draw a segment to n − 1 other vertices. Two of them are sides; so the number of diagonals from one vertex is n − 3.
Step 3. Summing over all vertices: n(n − 3). Each diagonal has two endpoints, so it was counted twice. Hence D = n(n − 3)/2.
Step 4 (combinatorial variant). The number of all segments among vertices is C(n, 2). Subtract n sides: C(n, 2) − n = n(n − 1)/2 − n = n(n − 3)/2. Both derivations are equivalent and standard in MathWorld and discrete-geometry texts.
n = 3: D = 0. n = 4: D = 2 (quadrilateral diagonals). n = 5: D = 5. n = 6: D = 9. n = 10: D = 35. n = 100: D = 4850. Parity check: n(n − 3) is always even for integer n ≥ 3, so D is an integer.
As n grows, D grows quadratically (~ n²/2). For large n drawing all diagonals becomes dense; the formula still gives the correct count, independent of visualization. For n < 3 the formula may formally give a negative or fractional value — outside the model domain.
Computation: D = n * (n - 3) / 2 for integer n ≥ 3. In a computer program prefer integer arithmetic or check that n is an integer. Division by 2 is exact when n(n−3) is even — always for integer n.
Non-integer input should be rejected or rounded only if the page clearly says so; this model assumes a vertex count. Comma/period do not change the meaning if the value must be integral. For very large n the result may exceed the largest exactly representable integer (2⁵³ − 1) — then big-integer arithmetic is needed.
Related tools: sum of interior angles ((n−2)·180°), number of triangles in a triangulation (n−2), perimeter and area of a regular polygon. The diagonal count does not depend on the circumradius — unlike side lengths.
Authorities: Euclid, Elements (polygons and dissections); MathWorld — Polygon Diagonal; combinatorics: C(n, 2) − n; standard school geometry texts. The calculator does not replace an exam proof — it evaluates D = n(n−3)/2. A useful cross-check is to compute C(n, 2) and subtract n sides: the difference must equal the displayed diagonal count for every integer n ≥ 3.
D = n(n − 3)/2 is the diagonal count of a convex n-gon. n = 4 gives 2. n = 5 gives 5. n = 6 gives 9.
2
How many diagonals does a quadrilateral have? 2.
5
How many diagonals does a pentagon have? 5.
9
How many diagonals does a hexagon have? 9.
0
How many diagonals does a triangle have? 0.
14
How many diagonals does a heptagon have? 14.
20
How many diagonals does an octagon have? 20.
35
How many diagonals does a decagon have? 35.
54
How many diagonals does a dodecagon have? 54.
For a convex n-gon the number of diagonals is D = n(n − 3)/2, where n is an integer and n ≥ 3. That is the standard school and combinatorial formula: each vertex sends n − 3 diagonals, and dividing by 2 removes double counting.
Two. With n = 4: D = 4×(4 − 3)/2 = 2. That is the first worked example on this page and the same fill from “Fill this example”.
Zero. With n = 3: D = 3×0/2 = 0, because every vertex is adjacent to the other two — there is no non-adjacent pair.
A pentagon (n = 5) has 5 diagonals. A hexagon (n = 6) has 9. Those are examples 2 and 3 on this page.
No. The calculator returns the count of diagonals, not their lengths. Length would need side lengths or coordinates; the only input here is n.
From each of the n vertices you draw n − 3 diagonals, for n(n − 3) directed ends in total. Each diagonal has two ends, so it appears twice in that product. Dividing by 2 gives the number of distinct diagonals.
Yes. A polygon has a whole number of vertices. A fraction such as 4.5 does not describe an n-gon on paper — the calculator rejects that input instead of multiplying blindly.
The complete graph Kₙ has C(n,2) = n(n − 1)/2 edges. Of those, n are the polygon sides and the rest are diagonals: C(n,2) − n = n(n − 3)/2. The result panel shows that check beside D.
Here the result is a count of segments (diagonals). The interior-angle sum is (n − 2)×180° — same n, different quantity. Use the related angle-sum page for degrees.
The expression n(n − 3)/2 equals −1, but n = 2 is not a polygon. The calculator requires n ≥ 3 and shows an error instead of a negative “result”.
Exactly n − 3. You skip yourself and the two neighbors on the boundary. For a hexagon that is 3; for a decagon, 7.
No. The result depends only on an integer n ≥ 3. The currency and unit settings in the page header do not affect this result.
Use D = n(n − 3)/2 with integer n ≥ 3. For n = 6: 6·3/2 = 9. Equivalently D = C(n,2) − n.
20. Computation: 8·(8 − 3)/2 = 40/2 = 20. That is Example 6 on this page.
35. Computation: 10·7/2 = 35. That is Example 7 on this page.
No. This page only counts segments between non-adjacent vertices. Diagonal lengths of specific shapes belong on separate calculators.
4850. Computation: 100·97/2 = 4850. Enter n = 100 to see the result in the panel.
The formula, derivation, and examples below come from established geometry and combinatorics references.
Page Updated November 2, 2026.