To find the nth nonagonal number in Swift, we can use the formula:
Nn = n(7n-5)/2
where n is the index of the nonagonal number.
Here is an implementation of this function in Swift:
main.swift77 chars4 linesTo use this function, simply call it with the index of the nonagonal number you want to find, like so:
main.swift126 chars4 linesThis will output 70, which is the 5th nonagonal number.
gistlibby LogSnag