main.php174 chars8 linesThe above code defines a function findNonagonal that accepts an argument n as input and returns the nth nonagonal number using the formula n(7n-5)/2.
To find the nth nonagonal number, we simply need to substitute the value of n in the formula provided and return the result.
The example usage demonstrates how to call the function and we see that the 5th nonagonal number is 70.
gistlibby LogSnag