To find the nth decagonal number, we can use the following formula:
dn = 3n^2 - 2n
Where n
is the position of the decagonal number in the sequence.
Here's the javascript code:
index.tsx132 chars7 lines
In this example, getDecagonalNumber(3)
will return 28, which is the 3rd decagonal number in the sequence (1, 10, 28, 55, ...).
gistlibby LogSnag