Placing any nn in a kk-polygonal diagram

Let n,kβˆˆβ„€+n,k\in\mathbb{Z}^{+}, k>2k>2. We would like to draw the kβˆ’k-polygonal number diagram β€œup to” nn. If nn happens to actually be a kβˆ’k-polygonal number, this will be a complete diagram with nn dots in a layered kk-polygon. Otherwise, this will be a diagram whose outer gnomon layer is incomplete.

Figure (3) shows hexagonal number (k=6k=6) diagrams for the numbers 15 and 26. Because 15 actually is a hexagonal number, the diagram is complete. The diagram for 26 shows an incomplete diagram, with an incomplete outer layer.

Refer to caption
Figure 3: Two hexagonal diagrams (k=6k=6), 15 is hexagonal, 26 is not

Finding the gnomon for nn and kk

The recursive definition for pk,1p_{k,1} in Equation (1 yields formulas stated as a summation (2) and a direct calculation (3).

pk,i=βˆ‘j=1i[(kβˆ’2)⁒jβˆ’(kβˆ’3)]p_{k,i}=\sum^{i}_{j=1}\left[(k-2)j-(k-3)\right] (2)
pk,i=(kβˆ’2)⁒i⁒(i+1)2βˆ’(kβˆ’3)⁒ip_{k,i}=\frac{(k-2)i(i+1)}{2}-(k-3)i (3)

Applying the quadratic formula to solve nβˆ’pk,i=0n-p_{k,i}=0 provides us with

g⁒(n,k)=(kβˆ’4)+(kβˆ’4)2+8⁒n⁒(kβˆ’2)2⁒(kβˆ’2)g\left(n,k\right)=\frac{\left(k-4\right)+\sqrt{\left(k-4\right)^{2}+8n\left(k-% 2\right)}}{2\left(k-2\right)} (4)

This allows us to identify the gnomon layer gnomon⁒(n,k)\text{gnomon}(n,k) that a given nn will sit in within a kk-polygonal diagram (5).

gnomon⁒(n,k)=ceil⁒(g⁒(n))\text{gnomon}\left(n,k\right)=\text{ceil}\left(g\left(n\right)\right) (5)

The position of nn within its gnomon layer

The size of the gnomon layer that nn will sit in (how many dots would be in the layer within the diagram) is given by Equation (6).

gsize⁒(n,k)=1+(gnomon⁒(n,k)βˆ’1)β‹…(kβˆ’2)\text{gsize}\left(n,k\right)=1+(\text{gnomon}\left(n,k\right)-1)\cdot\left(k-2\right) (6)

To find the position of the nnth dot within the gnomon, we need to count the number of dots that came before it within that gnomon. To do this we can sum up to nβˆ’1n-1 over a function whose value is 0 for all ii where g⁒n⁒o⁒m⁒o⁒n⁒(i,k)<g⁒n⁒o⁒m⁒o⁒n⁒(n,k)gnomon(i,k)<gnomon(n,k), and whose value is 11 for those ii where g⁒n⁒o⁒m⁒o⁒n⁒(i,k)=g⁒n⁒o⁒m⁒o⁒n⁒(n,k)gnomon(i,k)=gnomon(n,k). This sum that gives us the ”depth” of n within its gnomon is provided by Equation (7).

gdepth⁒(n,k)=βˆ‘i=1n(floor⁒(g⁒n⁒o⁒m⁒o⁒n⁒(i,k)g⁒n⁒o⁒m⁒o⁒n⁒(n,k)))\text{gdepth}\left(n,k\right)=\sum_{i=1}^{n}\left(\text{floor}\left(\frac{% gnomon\left(i,k\right)}{gnomon\left(n,k\right)}\right)\right) (7)