Skip to content

PrimorialNumbers ​

The primorials 2,6,30,210,…2, 6, 30, 210, … — pn#p_n\# — the product of the first nn primes.

PrimorialNumberspn#p_n\# for n=1,2,3,…n = 1, 2, 3, ….

Domain: Collections

Details
  • A lazy indexed collection: Count(PrimorialNumbers)=+∞Count(PrimorialNumbers) = +\infty, and At(PrimorialNumbers,k)=pk#At(PrimorialNumbers, k) = p_k\#, computed exactly over arbitrary-precision integers -- At(PrimorialNumbers,5)=2310At(PrimorialNumbers, 5) = 2310.
  • OEIS A002110, whose offset differs from ours: A002110 opens with the empty product a(0)=1a(0) = 1; this collection starts at n=1n=1 (value 22), so the empty product is not itself a member.
  • Membership goes through Element by growing the sequence forward until it reaches or passes the candidate -- Element(2310,PrimorialNumbers)Element(2310, PrimorialNumbers) is true, Element(2000,PrimorialNumbers)Element(2000, PrimorialNumbers) is false.

Definition

Epsil, as the implementation runs it.

count()

PositiveInfinity

unrank(_r)

Apply((pm_n: integer) => Apply(
                                (pm_f: list<integer>) => pm_f[2] if pm_f[1] ==
                                                                    pm_n else `NaN`,
                                Apply((pm_s_init: list<integer>) => Fold(
                                                                          (
                                                                            pm_s: list<integer>,
                                                                            pm_k,
                                                                          ) => Apply(
                                                                                     (pm_s_next: list<integer>) => pm_s_next,
                                                                                     ([
                                                                                        pm_s[1] + 1,
                                                                                        pm_s[2] * pm_k,
                                                                                      ] if pm_k >= 2 &&
                                                                                          Fold(
                                                                                                Function(ok_pd &&
                                                                                                         pm_k % pd !=
                                                                                                         0, ok_pd, pd),
                                                                                                True,
                                                                                                Range(2, Floor(Sqrt(pm_k)), 1),
                                                                                              ) else pm_s) if pm_s[1] < pm_n else pm_s,
                                                                                   ),
                                                                          pm_s_init,
                                                                          Range(
                                                                                 2,
                                                                                 11 if pm_n < 6 else Floor(pm_n *
                                                                                                           (Ln(pm_n) + Ln(Ln(pm_n)))) +
                                                                                                     1,
                                                                                 1,
                                                                               ),
                                                                        ), [0, 1]),
                              ), _r + 1)

rank(_x)

Apply(
       (pm_w: list<integer>) => `NaN` if pm_w[2] < _x else pm_w[3],
       Apply((pm_s_init: list<integer>) => Fold(
                                                 (pm_s: list<integer>, pm_k) => Apply(
                                                                                       (pm_s_next: list<integer>) => pm_s_next,
                                                                                       pm_s if pm_s[2] >= _x else Apply(
                                                                                                                         (pm_q: integer) => [pm_s[1] + 1, pm_q, pm_s[1] if pm_q == _x else pm_s[3]],
                                                                                                                         pm_s[2] * pm_k,
                                                                                                                       ) if pm_k >= 2 &&
                                                                                                                           Fold(Function(ok_pd &&
                                                                                                                                         pm_k % pd !=
                                                                                                                                         0, ok_pd, pd), True, Range(2, Floor(Sqrt(pm_k)), 1)) else pm_s,
                                                                                     ),
                                                 pm_s_init,
                                                 Apply(
                                                        (pm_c: integer) => Range(
                                                                                  2,
                                                                                  11 if pm_c < 6 else Floor(pm_c *
                                                                                                            (Ln(pm_c) + Ln(Ln(pm_c)))) +
                                                                                                      1,
                                                                                  1,
                                                                                ),
                                                        (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, 0],
                                                                      [
                                                                        8_192,
                                                                        4_096,
                                                                        2_048,
                                                                        1_024,
                                                                        512,
                                                                        256,
                                                                        128,
                                                                        64,
                                                                        32,
                                                                        16,
                                                                        8,
                                                                        4,
                                                                        2,
                                                                        1,
                                                                      ],
                                                                    ),
                                                              ) - 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, 0],
                                                                              [8_192, 4_096, 2_048, 1_024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],
                                                                            ),
                                                                      ) % 2) / 2 +
                                                        2,
                                                      ),
                                               ), [0, 1, -1]),
     ) if _x >= 2 else -1

valid(_x)

Apply(
       (pm_w: list<integer>) => `NaN` if pm_w[2] < _x else pm_w[3],
       Apply((pm_s_init: list<integer>) => Fold(
                                                 (pm_s: list<integer>, pm_k) => Apply(
                                                                                       (pm_s_next: list<integer>) => pm_s_next,
                                                                                       pm_s if pm_s[2] >= _x else Apply(
                                                                                                                         (pm_q: integer) => [pm_s[1] + 1, pm_q, pm_s[1] if pm_q == _x else pm_s[3]],
                                                                                                                         pm_s[2] * pm_k,
                                                                                                                       ) if pm_k >= 2 &&
                                                                                                                           Fold(Function(ok_pd &&
                                                                                                                                         pm_k % pd !=
                                                                                                                                         0, ok_pd, pd), True, Range(2, Floor(Sqrt(pm_k)), 1)) else pm_s,
                                                                                     ),
                                                 pm_s_init,
                                                 Apply(
                                                        (pm_c: integer) => Range(
                                                                                  2,
                                                                                  11 if pm_c < 6 else Floor(pm_c *
                                                                                                            (Ln(pm_c) + Ln(Ln(pm_c)))) +
                                                                                                      1,
                                                                                  1,
                                                                                ),
                                                        (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, 0],
                                                                      [
                                                                        8_192,
                                                                        4_096,
                                                                        2_048,
                                                                        1_024,
                                                                        512,
                                                                        256,
                                                                        128,
                                                                        64,
                                                                        32,
                                                                        16,
                                                                        8,
                                                                        4,
                                                                        2,
                                                                        1,
                                                                      ],
                                                                    ),
                                                              ) - 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, 0],
                                                                              [8_192, 4_096, 2_048, 1_024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],
                                                                            ),
                                                                      ) % 2) / 2 +
                                                        2,
                                                      ),
                                               ), [0, 1, -1]),
     ) >= 0 if _x >= 2 else False

Enumeration

Examples

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

See also: PrimeNumbers, FactorialNumbers, Count, At, Element