An icosagon is a twenty-sided polygon. Each segment-length was given its own color.
Please do not thing of the figure above as a decagon, but as a polygon with n sides — an n-gon, in other words. How many diagonals does it have? Well, first, there are n vertices for diagonals to come from, and three vertices they cannot go to — themselves, and the two immediately on either side of them, since the segments to those vertices are sides, not diagonals. That’s n vertices firing diagonals at n-3 other vertices, or (n)(n-3). However, that counts each diagonal exactly twice (once from each side), so the actual number of diagonals is half that: d=(n)(n-3)/2.
Now we can look at the polygon above, and use it to check this formula, by “remembering” that it is a decagon. With n = 10, d = (n)(n-3)/2 = (10)(7)/2 = 35.
Are there really 35 diagonals in the decagon above? Well, I made those of the same length into color-groups, to make them easier to count. There are five green ones, ten yellow ones, ten red ones, and ten pink ones, which does indeed total 35.
Suppose you know a polygon has, say, 104 diagonals. Can this formula be used to find the number of sides? Yes! Substituting 104 for d leads to this: 104 = (n)(n-3)/2, which then becomes 208 = (n)(n-3) = n² – 3n. To set this up for the quadratic formula, I’m rearranging it to n² – 3n – 208 = 0. The quadratic formula then states that n = (3 ± sqrt(9 – (4)(1)(-208)))/2 = (3 ± sqrt(9 + 832))/2 = (3 ± sqrt(841))/2 = (3 ± 29)/2 = (32 or -26)/2 = 16 or -13, and only one of these answers, 16, can be the number of sides of a polygon. Voila!