To find the nth decagonal number, we can use the formula:
dn = 3n^2 - 2n
where n is the index of the decagonal number.
We can create a function in Go to return the nth decagonal number using this formula:
main.go59 chars4 linesWe can then call this function with the desired value of n to find the corresponding decagonal number:
main.go47 chars2 lines
This will output 133, which is the 5th decagonal number.
gistlibby LogSnag