A quadrilateral has only 2 diagonals, but as you add one side at a time, the number of diagonals grows faster and faster. You can find the answer instantly with one formula instead of counting them all. Move the slider to change the number of sides and see what happens.
Why the formula works: From one vertex, you can draw diagonals only to the vertices other than itself and its two neighboring vertices. Since there are n vertices, that gives (n−3) possible diagonals from each vertex.
Multiplying this by all n vertices gives n(n−3), but then each diagonal is counted twice, once from each endpoint (for example, the diagonal from A to C is the same line as the diagonal from C to A). So we divide by 2 at the end to remove the duplicate counting.