Assuming these are all regular polygons, we use the fact that the sum of all exterior angles of a regular n-gon is 360°. So each exterior angle has measure 360°/n.
These angles are supplementary to the interior angles, so each interior angle has measure 180° - 360°/n.
Since there are n such angles, the sum of the interior angle measures is
n (180° - 360°/n) = 180° n - 360° = 180° (n - 2)
like in the given formula.
2. A heptagon has 7 sides, so the sum of its interior angle measures is 180° (7 - 2) = 900°
3. A decagon has 10 sides, so the interior angle sum is 180° (10 - 2) = 1440°