Skip to content

OdiousNumbers ​

The odious numbers 1,2,4,7,8,…1, 2, 4, 7, 8, …: positive integers with an odd number of 1-bits.

OdiousNumbersthe nn with an odd binary popcount, an infinite indexed collection.

Domain: Collections

Details
  • A lazy indexed collection: Count(OdiousNumbers)=+∞Count(OdiousNumbers) = +\infty, the complement of EvilNumbers among the positive integers. OEIS A000069.
  • At(OdiousNumbers,k)At(OdiousNumbers, k) unranks by scanning forward -- At(OdiousNumbers,4)=7At(OdiousNumbers, 4) = 7.
  • Membership goes through Element: Element(7,OdiousNumbers)Element(7, OdiousNumbers) is true (1112111_2, three 1-bits), Element(6,OdiousNumbers)Element(6, OdiousNumbers) is false (EvilNumbers).

Definition

Epsil, as the implementation runs it.

count()

PositiveInfinity

unrank(_r)

2 * _r + (1 - 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] == 1 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] == 1 if _x >=
                                                                           0 else False

Enumeration

Examples

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

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