AbundantNumbers
The abundant numbers -- integers whose proper divisors sum past them -- as a lazy indexed collection.
OEIS
A005101mathlib4Nat.AbundantAbundantNumbersthe with (proper-divisor sum exceeds ), an infinite indexed collection.Details
- A lazy indexed collection: , and unranks the -th abundant number by scanning forward from the last cached match -- .
- OEIS A005101.
- Membership goes through Element: is true, is false (perfect, not abundant).
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 (0 if sn_k < 2 else Fold(
Function(al_a +
(al_d if sn_k / al_d ==
al_d else al_d +
sn_k / al_d) if sn_k % al_d ==
0 else al_a, al_a, al_d),
1,
Range(2, Floor(Sqrt(sn_k)), 1),
)) >
sn_k else sn_s,
sn_s,
sn_k,
), 0, Range(1, 6 * (_r + 1 + 1), 1)),
)rank(_x)
Fold(
Function(
sn_c + 1 if (0 if sn_k < 2 else Fold(
Function(
al_a +
(al_d if sn_k /
al_d ==
al_d else al_d +
sn_k /
al_d) if sn_k % al_d ==
0 else al_a,
al_a,
al_d,
),
1,
Range(
2,
Floor(Sqrt(sn_k)),
1,
),
)) > sn_k else sn_c,
sn_c,
sn_k,
),
0,
Range(1, _x - 1, 1),
) if ((0 if _x < 2 else Fold(Function(
al_a +
(al_d if _x / al_d == al_d else al_d +
_x /
al_d) if _x % al_d == 0 else al_a,
al_a,
al_d,
), 1, Range(2, Floor(Sqrt(_x)), 1))) > _x if _x >= 1 else False) else -1valid(_x)
(0 if _x < 2 else Fold(
Function(
al_a + (al_d if _x / al_d == al_d else al_d +
_x /
al_d) if _x %
al_d ==
0 else al_a,
al_a,
al_d,
),
1,
Range(2, Floor(Sqrt(_x)), 1),
)) > _x if _x >= 1 else FalseEnumeration
Examples
See also: Count, At, Element, PrimeNumbers, SquareNumbers