A polygonal number is a type of figurate number that is a generalization of triangular, square,
etc., to an -gon
for
an arbitrary positive integer. The above diagrams graphically illustrate the process
by which the polygonal numbers are built up. Starting with the th triangular number , then

Call a number -highly
polygonal if it is -polygonal
in
or more ways out of ,
4, ... up to some limit. Then the first few 2-highly polygonal numbers up to are 1, 6, 9, 10, 12, 15, 16, 21,
28, (OEIS A090428). Similarly, the first few
3-highly polygonal numbers up to are 1, 15, 36, 45, 325, 561, 1225, 1540, 3025, ... (OEIS
A062712). There are no 4-highly polygonal numbers
of this type less than except for 1.

The generating function for the -gonal numbers is given by the beautiful formula

(6)

Fermat proposed that every number is expressible as at most -gonal numbers (Fermat's
polygonal number theorem). Fermat claimed to have a proof of this result, although
this proof has never been found. Jacobi, Lagrange (in 1772), and Euler all proved
the square case, and Gauss proved the triangular case in 1796. In 1813, Cauchy proved
the proposition in its entirety.

An arbitrary number
can be checked to see if it is a -gonal number as follows. Note the identity

(7)

so
must be a perfect square. Therefore, if it is not,
the number cannot be -gonal.
If it is a perfect square, then solving