One way to find the nth pentagonal number is to use the formula:
Pn = n(3n-1)/2
Here's a JavaScript function that implements this formula to find the nth pentagonal number:
index.tsx66 chars4 lines
To use this function, simply pass in the value of n as an argument:
index.tsx104 chars3 lines
This will output the nth pentagonal number for the given value of n.
gistlibby LogSnag