Skip to content

KFreeIntegers ​

The kk-free integers -- naturals with no prime factor raised to the kk-th power or higher -- as a lazy indexed family, one collection per kk.

KFreeIntegers(k)the positive integers whose every prime factor has exponent <k< k, an infinite indexed collection.
Typed signatures
TypePackageApplies
(integer<0..>) -> indexed_collection<integer>combinatoricsalways

Domain: Collections

Details
  • A lazy indexed collection for each kk: Count(KFreeIntegers(k))=+∞Count(KFreeIntegers(k)) = +\infty, and At(KFreeIntegers(k),i)At(KFreeIntegers(k), i) unranks the ii-th by scanning forward, testing each candidate's factorisation against kk.
  • KFreeIntegers(2)KFreeIntegers(2) is exactly SquareFreeNumbers (A005117); KFreeIntegers(3)KFreeIntegers(3) is the cube-free numbers, A004709.
  • Membership goes through Element: Element(8,KFreeIntegers(3))Element(8, KFreeIntegers(3)) is false (8=238 = 2^3, exponent 3≥33 \ge 3), Element(8,KFreeIntegers(4))Element(8, KFreeIntegers(4)) is true.

Definition

Epsil, as the implementation runs it.

count(_k)

1 if _k < 2 else PositiveInfinity

unrank(_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(ok_kf &&
                                                                                                              sn_k %
                                                                                                              kf ^ _k !=
                                                                                                              0, ok_kf, kf),
                                                                                                     True,
                                                                                                     Range(2, Floor(Sqrt(sn_k)), 1),
                                                                                                   )) else sn_s,
                      sn_s,
                      sn_k,
                    ), 0, Range(1, 1 if _k < 2 else 2 * (_r + 1), 1)),
     )

rank(_k, _x)

Fold(
      Function(sn_c + 1 if (sn_k == 1 if _k < 2 else Fold(
                                                           Function(
                                                                     ok_kf && sn_k %
                                                                              kf ^
                                                                              _k !=
                                                                              0,
                                                                     ok_kf,
                                                                     kf,
                                                                   ),
                                                           True,
                                                           Range(
                                                                  2,
                                                                  Floor(Sqrt(sn_k)),
                                                                  1,
                                                                ),
                                                         )) else sn_c, sn_c, sn_k),
      0,
      Range(1, _x - 1, 1),
    ) if ((_x == 1 if _k < 2 else Fold(
                                       Function(
                                                 ok_kf && _x % kf ^ _k != 0,
                                                 ok_kf,
                                                 kf,
                                               ),
                                       True,
                                       Range(2, Floor(Sqrt(_x)), 1),
                                     )) if _x >= 1 else False) else -1

valid(_k, _x)

(_x == 1 if _k < 2 else Fold(
                              Function(ok_kf && _x % kf ^ _k != 0, ok_kf, kf),
                              True,
                              Range(2, Floor(Sqrt(_x)), 1),
                            )) if _x >= 1 else False

Enumeration

Examples

1 more kept as data, checked against the oracles
Scope #

At k=2k=2, agrees with SquareFreeNumbers

live ↗
InTake(KFreeIntegers(2),10)\mathrm{Take}(\mathrm{KFreeIntegers}(2), 10)Out[1,2,3,5,6,7,10,11,13,14]\bigl\lbrack1, 2, 3, 5, 6, 7, 10, 11, 13, 14\bigr\rbrack
About
Examples2

See also: Count, At, Element, SquareFreeNumbers