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[1]:=
`Table[PolygonalNumber[n], {n, 1, 10}]`
Out[1]=

Return the tenth -gonal number of several regular polygons.

In[2]:=
`Table[PolygonalNumber[r, 10], {r, 3, 10}]`
Out[2]=

A polygonal number counts the number of equally spaced points in a regular geometrical arrangement of this type.

show complete Wolfram Language input
In[3]:=
```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[4]:=
```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[5]:=
```PolygonalNumber[3, 4] polygonalNumberGraphics[3, 4]```
Out[5]=
Out[5]=
In[6]:=
```PolygonalNumber[3, 6] polygonalNumberGraphics[3, 6]```
Out[6]=
Out[6]=
In[7]:=
```PolygonalNumber[6, 5] polygonalNumberGraphics[6, 5]```
Out[7]=
Out[7]=