Skip to content

PentagonalNumbers ​

The pentagonal numbers 1,5,12,22,…1, 5, 12, 22, … — P(n)=n(3n−1)/2P(n) = n(3n-1)/2 — dots in a pentagon.

PentagonalNumbersP(n)=n(3n−1)/2P(n) = n(3n-1)/2 for n=1,2,3,…n = 1, 2, 3, ….

Domain: Collections

Details
  • A lazy indexed collection: Count(PentagonalNumbers)=+∞Count(PentagonalNumbers) = +\infty, and At(PentagonalNumbers,k)=k(3k−1)/2At(PentagonalNumbers, k) = k(3k-1)/2 unranks in closed form -- At(PentagonalNumbers,5)=35At(PentagonalNumbers, 5) = 35.
  • OEIS A000326.
  • Membership goes through Element by inverting the closed form exactly, solving the quadratic in nn over the integers -- Element(35,PentagonalNumbers)Element(35, PentagonalNumbers) is true, Element(36,PentagonalNumbers)Element(36, PentagonalNumbers) is false.
  • The kk-gonal case k=5k=5 of PolygonalNumbers; not to be confused with the (signed-index) generalized pentagonal numbers of Euler's pentagonal number theorem.

Definition

Epsil, as the implementation runs it.

count()

PositiveInfinity

unrank(_r)

(_r + 1) * (3 * (_r + 1) - 1) / 2

rank(_x)

Apply(
       (sq_at: integer) => sq_at if (sq_at + 1) * (3 * (sq_at + 1) - 1) / 2 ==
                                    _x else -1,
       Fold(Function(
                      sq_at + 2 ^ sq_b if (sq_at + 2 ^ sq_b + 1) * (3 * (sq_at +
                                                                         2 ^
                                                                         sq_b + 1) -
                                                                    1) / 2 <= _x else sq_at,
                      sq_at,
                      sq_b,
                    ), 0, Range(Floor(Log(_x, 2)) + 1, 0, -1)),
     ) if True else -1

valid(_x)

Apply(
       (sq_at: integer) => (sq_at + 1) * (3 * (sq_at + 1) - 1) / 2 == _x,
       Fold(Function(
                      sq_at + 2 ^ sq_b if (sq_at + 2 ^ sq_b + 1) * (3 * (sq_at +
                                                                         2 ^
                                                                         sq_b + 1) -
                                                                    1) / 2 <= _x else sq_at,
                      sq_at,
                      sq_b,
                    ), 0, Range(Floor(Log(_x, 2)) + 1, 0, -1)),
     ) if True && _x >= 1 else False

Enumeration

Examples

1 more kept as data, checked against the oracles
About
Examples1
CrosswalkOEISWolfram LanguageSageMath

See also: PolygonalNumbers, TriangularNumbers, HexagonalNumbers, Count, At, Element