Skip to content

SquarePyramidalNumbers ​

The square pyramidal numbers 1,5,14,30,…1, 5, 14, 30, … — n(n+1)(2n+1)/6n(n+1)(2n+1)/6 — stacked squares, partial sums of the square numbers.

SquarePyramidalNumbersn(n+1)(2n+1)/6n(n+1)(2n+1)/6 for n=1,2,3,…n = 1, 2, 3, ….

Domain: Collections

Details
  • A lazy indexed collection: Count(SquarePyramidalNumbers)=+∞Count(SquarePyramidalNumbers) = +\infty, and At(SquarePyramidalNumbers,k)=k(k+1)(2k+1)/6At(SquarePyramidalNumbers, k) = k(k+1)(2k+1)/6 unranks in closed form -- At(SquarePyramidalNumbers,5)=55At(SquarePyramidalNumbers, 5) = 55.
  • OEIS A000330.
  • Membership goes through Element by bisecting the monotone cubic for its exact root -- Element(55,SquarePyramidalNumbers)Element(55, SquarePyramidalNumbers) is true, Element(56,SquarePyramidalNumbers)Element(56, SquarePyramidalNumbers) is false.
  • SquarePyramidalNumbers(n)=∑i=1nSquareNumbers(i)SquarePyramidalNumbers(n) = \sum_{i=1}^n SquareNumbers(i).

Definition

Epsil, as the implementation runs it.

count()

PositiveInfinity

unrank(_r)

Binomial(_r + 3, 3) + Binomial(_r + 2, 3)

rank(_x)

Apply(
       (sq_at: integer) => sq_at if Binomial(sq_at + 3, 3) + Binomial(
                                                                       sq_at + 2,
                                                                       3,
                                                                     ) == _x else -1,
       Fold(
             Function(sq_at + 2 ^ sq_b if Binomial(sq_at + 2 ^ sq_b + 3, 3) +
                                          Binomial(sq_at + 2 ^ sq_b + 2, 3) <= _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) => Binomial(sq_at + 3, 3) + Binomial(sq_at + 2, 3) == _x,
       Fold(
             Function(sq_at + 2 ^ sq_b if Binomial(sq_at + 2 ^ sq_b + 3, 3) +
                                          Binomial(sq_at + 2 ^ sq_b + 2, 3) <= _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
CrosswalkOEIS

See also: SquareNumbers, TetrahedralNumbers, Count, At, Element