SmoothNumbers
The -smooth numbers -- positive integers with every prime factor -- as a lazy indexed family, one collection per .
SmoothNumbers(k)the positive integers whose prime factors are all , an infinite indexed collection.Typed signatures
| Type | Package | Applies |
|---|---|---|
(integer<0..>) -> indexed_collection<integer> | combinatorics | always |
Details
- A lazy indexed collection for each : , and unranks the -th -smooth number -- (vacuously smooth).
- 7-smooth numbers are OEIS A002473.
- Membership goes through Element: is true (its factors ), is false ().
Definition
Epsil, as the implementation runs it.
count(_k)
1 if _k < 2 else PositiveInfinityunrank(_k, _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 ==
1 if _k < 2 else Fold(
Function(sm_w if sm_w[1] == 1 ||
sm_w[2] > _k else [sm_w[1] / sm_w[2], sm_w[2]] if sm_w[1] % sm_w[2] ==
0 else [sm_w[1], sm_w[2] + 1], sm_w, sm_i),
[sn_k, 2],
Range(1, _k +
Floor(Log(sn_k, 2)) +
1, 1),
)[1] ==
1) else sn_s,
sn_s,
sn_k,
), 0, Range(1, 1 if _k < 2 else 2 ^ (_r + 1 - 1), 1)),
)rank(_k, _x)
Fold(
Function(sn_c + 1 if (sn_k == 1 if _k < 2 else Fold(
Function(
sm_w if sm_w[1] ==
1 ||
sm_w[2] >
_k else [
sm_w[1] / sm_w[2],
sm_w[2],
] if sm_w[1] % sm_w[2] ==
0 else [sm_w[1], sm_w[2] + 1],
sm_w,
sm_i,
),
[sn_k, 2],
Range(
1,
_k +
Floor(Log(
sn_k,
2,
)) + 1,
1,
),
)[1] == 1) else sn_c, sn_c, sn_k),
0,
Range(1, _x - 1, 1),
) if ((_x == 1 if _k < 2 else Fold(
Function(
sm_w if sm_w[1] == 1 || sm_w[2] >
_k else [
sm_w[1] / sm_w[2],
sm_w[2],
] if sm_w[1] % sm_w[2] ==
0 else [sm_w[1], sm_w[2] + 1],
sm_w,
sm_i,
),
[_x, 2],
Range(1, _k + Floor(Log(_x, 2)) + 1, 1),
)[1] == 1) if _x >= 1 else False) else -1valid(_k, _x)
(_x == 1 if _k < 2 else Fold(Function(
sm_w if sm_w[1] == 1 || sm_w[2] > _k else [
sm_w[1] / sm_w[2],
sm_w[2],
] if sm_w[1] % sm_w[2] ==
0 else [sm_w[1], sm_w[2] + 1],
sm_w,
sm_i,
), [_x, 2], Range(1, _k +
Floor(Log(_x, 2)) + 1, 1))[1] == 1) if _x >=
1 else FalseEnumeration
Examples
About
| Examples | 1 |
|---|
See also: Count, At, Element, PrimeNumbers