Hexagonal Number - GeeksforGeeks
Given an integer n, the task is to find the n'th hexagonal number . The n'th hexagonal number Hn is the number of distinct dots in a pattern of dots consisting of the outlines of regular hexagons with sides up to n dots, when the hexagons are overlaid so that they share one vertex.{Source : wiki}
Input : n = 2 Output : 6 Input : n = 5 Output : 45 Input : n = 7 Output : 91
We strongly recommend you to minimize your browser and try this yourself first.
In general, a polygonal number (triangular number, square number, etc) is a number represented as dots or pebbles arranged in the shape of a regular polygon. The first few pentagonal numbers are: 1, 5, 12, etc.
If s is the number of sides in a polygon, the formula for the nth s-gonal number P (s, n) is
Read full article from Hexagonal Number - GeeksforGeeks
No comments:
Post a Comment