Here is how to find the nth hexagonal number in Go using the formula n(2n-1):
main.go273 chars17 linesIn the above code, we define a function nthHexagonalNumber that receives an integer n and returns the nth hexagonal number using the formula n(2n-1). In the main function, we call nthHexagonalNumber passing the value of the nth number we want to find and print the result to the console.
gistlibby LogSnag