PrimorialNumbers
The primorials — — the product of the first primes.
OEIS
A002110mathlib4Nat.primorialPrimorialNumbers for .Details
- A lazy indexed collection: , and , computed exactly over arbitrary-precision integers -- .
- OEIS A002110, whose offset differs from ours: A002110 opens with the empty product ; this collection starts at (value ), 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 -- is true, is false.
Definition
Epsil, as the implementation runs it.
count()
PositiveInfinityunrank(_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 -1valid(_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 FalseEnumeration
Examples
1 more kept as data, checked against the oracles See also: PrimeNumbers, FactorialNumbers, Count, At, Element