Definition:Hexagonal Number

Hexagonal numbers are those denumerating a collection of objects which can be arranged in the form of a regular hexagon.

They are otherwise called hexagon numbers.

Or we can just say that a number is hexagonal.

They can be denoted $$H_1, H_2, H_3, \ldots$$, and they are formally defined as:
 * $$H_n = \sum_{i=1}^n [4(i - 1) + 1] = 1 + 5 + \cdots + \left({4 \left({n-2}\right) + 1}\right) + \left({4 \left({n-1}\right) + 1}\right)$$.

Thus $$H_0 = 0$$ and $$H_1 = 1$$.



The second hexagonal number: $$H_2 = 1 + 5 = 6$$.



The third hexagonal number: $$H_3 = 1 + 5 + 9 = 15$$.

Recurrence Formula
It can be seen directly from the above that:
 * $$H_n = \begin{cases}

0 & : n = 0 \\ H_{n-1} + 4 \left({n-1}\right) + 1 & : n > 0 \end{cases}$$

Closed Form
From Closed Form for Polygonal Number‎s, we have (after some algebra):
 * $$H_n = n \left({2 n - 1}\right)$$