# Deriving formulas for the polygonal numbers

For the entirety of this article, let \(s\) be the number of sides, for the polygonal number, and \(n\) the number of points per edge.

$$P(s, n) = (s - 2)\dfrac{n(n + 1)}{2} - (s - 3)n$$

- \(s - 2\) triangles, \(n(n + 1)/2\) points per triangle
- \(s - 3\) diagonals were counted twice, \(n\) points per diagonal

$$P(s, n) = (s - 2)\dfrac{n(n - 1)}{2} + n$$

- \(s - 2\) triangles, \(n(n - 1)/2\) points per triangle
- \(1\) edge wasn't counted, \(n\) points per edge

Note that each of these formulas can be derived from the other by elementary algebra.