Skip to content

EvilNumbers ​

The evil numbers 0,3,5,6,9,…0, 3, 5, 6, 9, …: nonnegative integers with an even number of 1-bits.

EvilNumbersthe n≥0n \geq 0 with an even binary popcount, an infinite indexed collection.

Domain: Collections

Details
  • A lazy indexed collection: Count(EvilNumbers)=+∞Count(EvilNumbers) = +\infty, and this is the one family here whose first term is 0 rather than 1 (popcount 0 is even). OEIS A001969.
  • At(EvilNumbers,k)At(EvilNumbers, k) unranks by scanning forward -- At(EvilNumbers,1)=0At(EvilNumbers, 1) = 0, At(EvilNumbers,2)=3At(EvilNumbers, 2) = 3.
  • Membership goes through Element: Element(6,EvilNumbers)Element(6, EvilNumbers) is true (1102110_2, two 1-bits), Element(7,EvilNumbers)Element(7, EvilNumbers) is false (OdiousNumbers, three 1-bits).

Definition

Epsil, as the implementation runs it.

count()

PositiveInfinity

unrank(_r)

2 * _r + Fold(
               Function([(bt_s[1] - bt_s[1] % 2) / 2, (bt_s[2] + bt_s[1] % 2) %
                                                      2], bt_s, bt_b),
               [_r, 0],
               Range(1, Floor(Log(_r + 1, 2)) + 2, 1),
             )[2]

rank(_x)

(_x - _x % 2) / 2 if _x >= 0 && Fold(
                                      Function([
                                                 (bt_s[1] - bt_s[1] % 2) / 2,
                                                 (bt_s[2] + bt_s[1] % 2) % 2,
                                               ], bt_s, bt_b),
                                      [_x, 0],
                                      Range(1, Floor(Log(_x + 1, 2)) + 2, 1),
                                    )[2] == 0 else -1

valid(_x)

Fold(Function(
               [(bt_s[1] - bt_s[1] % 2) / 2, (bt_s[2] + bt_s[1] % 2) % 2],
               bt_s,
               bt_b,
             ), [_x, 0], Range(1, Floor(Log(_x + 1, 2)) + 2, 1))[2] == 0 if _x >=
                                                                           0 else False

Enumeration

Examples

1 more kept as data, checked against the oracles
About
Examples1
CrosswalkOEIS

See also: Count, At, Element, OdiousNumbers, PerniciousNumbers