Skip to content

FubiniNumbers ​

The Fubini numbers (ordered Bell numbers) 1,1,3,13,75,541,…1, 1, 3, 13, 75, 541, … as a lazy indexed collection.

FubiniNumbersThe number of ordered set partitions (rankings with ties allowed) of an nn-set, an infinite indexed collection.

Domain: Collections

Details
  • A lazy indexed collection: Count(FubiniNumbers)=+∞Count(FubiniNumbers) = +\infty, and At(FubiniNumbers,k)At(FubiniNumbers, k) unranks term k−1k-1 via a(n)=∑j=1n(nj)a(n−j)a(n) = \sum_{j=1}^{n} \binom{n}{j} a(n-j), bigint throughout -- At(FubiniNumbers,1)=a(0)=1At(FubiniNumbers, 1) = a(0) = 1.
  • OEIS A000670, starting exactly at its offset-0 term: 1,1,3,13,75,541,4683,…1, 1, 3, 13, 75, 541, 4683, ….
  • Membership goes through Element: Element(75,FubiniNumbers)Element(75, FubiniNumbers) is true, Element(20,FubiniNumbers)Element(20, FubiniNumbers) is false.

Definition

Epsil, as the implementation runs it.

count()

PositiveInfinity

unrank(_r)

Apply((hs_l: integer) => Apply((hs_n: integer) => Fold(
                                                        Function(hs_t if False else Join(
                                                                                          hs_t,
                                                                                          [Fold(
                                                                                                 Function(hs_a +
                                                                                                          Binomial(hs_m, hs_j - 1) *
                                                                                                          hs_t[hs_j], hs_a, hs_j),
                                                                                                 0,
                                                                                                 Range(1, hs_m, 1),
                                                                                               )],
                                                                                        ), hs_t, hs_m),
                                                        [1],
                                                        Range(1, hs_l, 1),
                                                      ), 0), _r)[_r + 1]

rank(_x)

Apply((hs_b: integer) => Apply(
                                (hs_all: list<integer>) => Fold(
                                                                 Function(
                                                                           (hs_i if hs_p < 0 &&
                                                                                    hs_all[hs_i + 1] ==
                                                                                    _x else hs_p) if hs_i < Length(hs_all) else hs_p,
                                                                           hs_p,
                                                                           hs_i,
                                                                         ),
                                                                 -1,
                                                                 Range(
                                                                        0,
                                                                        hs_b,
                                                                        1,
                                                                      ),
                                                               ),
                                Apply((hs_l: integer) => Apply((hs_n: integer) => Fold(
                                                                                        Function(
                                                                                                  hs_t if hs_t[Length(hs_t)] > _x else Join(hs_t, [Fold(Function(hs_a +
                                                                                                                                                                 Binomial(hs_m, hs_j - 1) *
                                                                                                                                                                 hs_t[hs_j], hs_a, hs_j), 0, Range(1, hs_m, 1))]),
                                                                                                  hs_t,
                                                                                                  hs_m,
                                                                                                ),
                                                                                        [1],
                                                                                        Range(1, hs_l, 1),
                                                                                      ), 0), hs_b),
                              ), Apply(
                                       (fl_r: list<integer>) => fl_r[2],
                                       Fold(Function(
                                                      [(fl_s[1] - fl_s[1] % 2 ^
                                                                            fl_k) /
                                                       2 ^ fl_k, fl_s[2] + fl_k] if fl_s[1] >=
                                                                            2 ^
                                                                            fl_k else fl_s,
                                                      fl_s,
                                                      fl_k,
                                                    ), [_x + 2, 0], [
                                                                     8_192,
                                                                     4_096,
                                                                     2_048,
                                                                     1_024,
                                                                     512,
                                                                     256,
                                                                     128,
                                                                     64,
                                                                     32,
                                                                     16,
                                                                     8,
                                                                     4,
                                                                     2,
                                                                     1,
                                                                   ]),
                                     ) + 3) if _x >= 0 else -1

valid(_x)

Apply((hs_b: integer) => Apply(
                                (hs_all: list<integer>) => Fold(
                                                                 Function(
                                                                           (hs_i if hs_p < 0 &&
                                                                                    hs_all[hs_i + 1] ==
                                                                                    _x else hs_p) if hs_i < Length(hs_all) else hs_p,
                                                                           hs_p,
                                                                           hs_i,
                                                                         ),
                                                                 -1,
                                                                 Range(
                                                                        0,
                                                                        hs_b,
                                                                        1,
                                                                      ),
                                                               ),
                                Apply((hs_l: integer) => Apply((hs_n: integer) => Fold(
                                                                                        Function(
                                                                                                  hs_t if hs_t[Length(hs_t)] > _x else Join(hs_t, [Fold(Function(hs_a +
                                                                                                                                                                 Binomial(hs_m, hs_j - 1) *
                                                                                                                                                                 hs_t[hs_j], hs_a, hs_j), 0, Range(1, hs_m, 1))]),
                                                                                                  hs_t,
                                                                                                  hs_m,
                                                                                                ),
                                                                                        [1],
                                                                                        Range(1, hs_l, 1),
                                                                                      ), 0), hs_b),
                              ), Apply(
                                       (fl_r: list<integer>) => fl_r[2],
                                       Fold(Function(
                                                      [(fl_s[1] - fl_s[1] % 2 ^
                                                                            fl_k) /
                                                       2 ^ fl_k, fl_s[2] + fl_k] if fl_s[1] >=
                                                                            2 ^
                                                                            fl_k else fl_s,
                                                      fl_s,
                                                      fl_k,
                                                    ), [_x + 2, 0], [
                                                                     8_192,
                                                                     4_096,
                                                                     2_048,
                                                                     1_024,
                                                                     512,
                                                                     256,
                                                                     128,
                                                                     64,
                                                                     32,
                                                                     16,
                                                                     8,
                                                                     4,
                                                                     2,
                                                                     1,
                                                                   ]),
                                     ) + 3) >= 0 if _x >= 0 else False

Enumeration

Examples

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

See also: Count, At, Element, BellNumbers