SquareFreeNumbers
The squarefree numbers -- integers divisible by no perfect square -- as a lazy indexed collection.
OEIS
A005117mathlib4SquarefreeSquareFreeNumbersthe with every prime factor's exponent , an infinite indexed collection.Details
- A lazy indexed collection: (density ), and unranks the -th by scanning forward, testing each candidate's factorisation.
- OEIS A005117. Exactly -- the two families are unranked identically.
- Membership goes through Element: is true (), is false ().
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(ok_sf &&
sn_k %
(sf * sf) !=
0, ok_sf, sf),
True,
Range(2, Floor(Sqrt(sn_k)), 1),
) else sn_s,
sn_s,
sn_k,
), 0, Range(1, 2 * (_r + 1), 1)),
)rank(_x)
Fold(Function(
sn_c + 1 if Fold(Function(
ok_sf && sn_k % (sf * sf) != 0,
ok_sf,
sf,
), True, Range(2, Floor(Sqrt(sn_k)), 1)) else sn_c,
sn_c,
sn_k,
), 0, Range(1, _x - 1, 1)) if (Fold(
Function(
ok_sf && _x % (sf *
sf) != 0,
ok_sf,
sf,
),
True,
Range(2, Floor(Sqrt(_x)), 1),
) if _x >= 1 else False) else -1valid(_x)
Fold(
Function(ok_sf && _x % (sf * sf) != 0, ok_sf, sf),
True,
Range(2, Floor(Sqrt(_x)), 1),
) if _x >= 1 else FalseEnumeration
Examples
1 more kept as data, checked against the oracles See also: Count, At, Element, KFreeIntegers, PowerfulNumbers