# Wolfram Language™

## Polygonal Numbers

Polygonal numbers are a type of figurate numbers. They generalize triangular numbers, square numbers, etc. to any -gon.

Return the first 10 triangular numbers.

In:= `Table[PolygonalNumber[n], {n, 1, 10}]`
Out= Return the tenth -gonal number of several regular polygons.

In:= `Table[PolygonalNumber[r, 10], {r, 3, 10}]`
Out= A polygonal number counts the number of equally spaced points in a regular geometrical arrangement of this type.

show complete Wolfram Language input
In:= ```points[0, r_] := {{0, 0}}; points[n_, r_] := Flatten[Subdivide[#1, #2, n] & @@@ Partition[CirclePoints[-Last[CirclePoints[n, r]], n, r], 2, 1, 1], 1]; points[ns_List, r_] := points[#, r] & /@ ns;```
In:= ```polygonalNumberGraphics[r_, n_] := With[{ps = points[Range[0, n - 1], r]}, Graphics[{PointSize[Large], Point /@ ps, Line /@ ps, Opacity[0.2], RandomColor[], Polygon /@ ps}]]```
In:= ```PolygonalNumber[3, 4] polygonalNumberGraphics[3, 4]```
Out= Out= In:= ```PolygonalNumber[3, 6] polygonalNumberGraphics[3, 6]```
Out= Out= In:= ```PolygonalNumber[6, 5] polygonalNumberGraphics[6, 5]```
Out= Out= 