PrimeNumbers
The prime numbers as a lazy indexed collection, unranked by position.
PrimeNumbersthe primes in increasing order, an infinite indexed collection.Details
- A lazy indexed collection: , and unranks the -th prime without ever sieving a full prefix -- .
- OEIS A000040.
- Membership goes through Element: is true, is false.
- Distinct from Primes, compute-engine's own
set<integer>constant: a value can't be extended, so the two don't share one name. - Past membership is a Baillie–PSW test: a proof below , and above it a probable-prime test (no composite is known to pass it), as Wolfram's
PrimeQis. Past , and for the position of a prime past about , Element and the rank stay unevaluated.
Definition
Epsil, as the implementation runs it.
count()
PositiveInfinityunrank(_r)
Apply(
(sn_f: integer) => sn_f if sn_f > 0 else `NaN`,
Fold(
Function(sn_s if sn_s > 0 else (sn_k if sn_s + _r == 0 else sn_s -
1) if sn_k >=
2 &&
Fold(
Function(ok_pd &&
sn_k % pd !=
0, ok_pd, pd),
True,
Range(2, Floor(Sqrt(sn_k)), 1),
) else sn_s, sn_s, sn_k),
0,
Range(
1,
Apply(
(pb_n: integer) => 11 if pb_n < 6 else Floor(pb_n *
(Ln(pb_n) +
Ln(Ln(pb_n)))) + 1,
_r + 1,
),
1,
),
),
)rank(_x)
Fold(
Function(sn_c + 1 if sn_k >= 2 && Fold(
Function(
ok_pd && sn_k % pd != 0,
ok_pd,
pd,
),
True,
Range(2, Floor(Sqrt(sn_k)), 1),
) else sn_c, sn_c, sn_k),
0,
Range(1, _x - 1, 1),
) if (_x >= 2 && Fold(
Function(ok_pd && _x % pd != 0, ok_pd, pd),
True,
Range(2, Floor(Sqrt(_x)), 1),
) if _x >= 1 else False) else -1valid(_x)
_x >= 2 && Fold(
Function(ok_pd && _x % pd != 0, ok_pd, pd),
True,
Range(2, Floor(Sqrt(_x)), 1),
) if _x >= 1 else FalseEnumeration
Examples
2 more kept as data, checked against the oracles See also: Primes, Count, At, Element, SquareNumbers, AbundantNumbers, SmoothNumbers