Hexagonal number

A hexagonal number is a figurate number, the number of points in the union of n hexagons with partly two common sides, as shown in [1]. The hexagonal number for n is given by the formula 2n2 - n. The first few hexagonal numbers (sequence A000384 in OEIS) are:

1, 6, 15, 28, 45, 66, 91, 120, 153, 190, 231, 276, 325, 378, 435, 496, 561, 630, 703, 780, 861, 946

Every hexagonal number is a triangular number, but not every triangular number is a hexagonal number. Like a triangular number, the digital root in base 10 of a hexagonal number can only be 1, 3, 6, or 9.

Any integer greater than 1791 can be expressed as a sum of at most four hexagonal numbers, a fact proven by Adrien-Marie Legendre in 1830.

Hexagonal numbers can be rearranged into rectangular numbers n long and 2n - 1 tall (or viceversa).

Hexagonal numbers should not be confused with centered hexagonal numbers, which model the standard packaging of Vienna sausages. To avoid ambiguity, hexagonal numbers are sometimes called "cornered hexagonal numbers".