PowerfulNumbers
The powerful numbers -- integers where every prime factor appears squared or more -- as a lazy indexed collection.
OEIS
A001694PowerfulNumbersthe whose every prime factor has exponent , an infinite indexed collection.Details
- A lazy indexed collection: (every perfect square is powerful), and unranks the -th by scanning forward, testing each candidate's factorisation.
- OEIS A001694. Every powerful number factors uniquely as for squarefree .
- Membership goes through Element: is true (), is false (, and 's exponent is only ).
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 Fold(
Function(pw_f ||
pw_b ^ 3 <=
sn_k &&
sn_k %
pw_b ^ 3 ==
0 &&
Round(Sqrt(sn_k /
pw_b ^ 3)) *
Round(Sqrt(sn_k /
pw_b ^ 3)) ==
sn_k /
pw_b ^ 3, pw_f, pw_b),
False,
Range(1, Floor(sn_k ^
(1 / 3)) +
2, 1),
) else sn_s,
sn_s,
sn_k,
), 0, Range(1, (_r + 1) ^ 2, 1)),
)rank(_x)
Fold(Function(sn_c + 1 if Fold(
Function(pw_f || pw_b ^ 3 <= sn_k && sn_k % pw_b ^
3 ==
0 && Round(Sqrt(sn_k /
pw_b ^ 3)) *
Round(Sqrt(sn_k /
pw_b ^ 3)) == sn_k /
pw_b ^
3, pw_f, pw_b),
False,
Range(1, Floor(sn_k ^ (1 / 3)) + 2, 1),
) else sn_c, sn_c, sn_k), 0, Range(1, _x - 1, 1)) if (Fold(
Function(pw_f ||
pw_b ^ 3 <=
_x &&
_x %
pw_b ^ 3 ==
0 &&
Round(Sqrt(_x /
pw_b ^ 3)) *
Round(Sqrt(_x /
pw_b ^ 3)) ==
_x /
pw_b ^ 3, pw_f, pw_b),
False,
Range(1, Floor(_x ^
(1 / 3)) +
2, 1),
) if _x >= 1 else False) else -1valid(_x)
Fold(
Function(
pw_f || pw_b ^ 3 <= _x && _x % pw_b ^ 3 == 0 && Round(Sqrt(_x /
pw_b ^
3)) *
Round(Sqrt(_x /
pw_b ^
3)) == _x / pw_b ^
3,
pw_f,
pw_b,
),
False,
Range(1, Floor(_x ^ (1 / 3)) + 2, 1),
) if _x >= 1 else FalseEnumeration
Examples
1 more kept as data, checked against the oraclesAbout
| Examples | 3 |
|---|---|
| Crosswalk | OEIS |
See also: Count, At, Element, SquareFreeNumbers, PerfectPowerNumbers