A381962 Irregular triangle read by rows, where row n lists the iterates of f(x), starting at x = n until f(x) <= 1, where f(x) is the Hamming weight of x (A000120).
0, 1, 2, 1, 3, 2, 1, 4, 1, 5, 2, 1, 6, 2, 1, 7, 3, 2, 1, 8, 1, 9, 2, 1, 10, 2, 1, 11, 3, 2, 1, 12, 2, 1, 13, 3, 2, 1, 14, 3, 2, 1, 15, 4, 1, 16, 1, 17, 2, 1, 18, 2, 1, 19, 3, 2, 1, 20, 2, 1, 21, 3, 2, 1, 22, 3, 2, 1, 23, 4, 1, 24, 2, 1, 25, 3, 2, 1, 26, 3, 2, 1
Offset: 0
Examples
Triangle begins: n\k| 0 1 2 3 ---------------- 0 | 0; 1 | 1; 2 | 2, 1; 3 | 3, 2, 1; 4 | 4, 1; 5 | 5, 2, 1; 6 | 6, 2, 1; 7 | 7, 3, 2, 1; 8 | 8, 1; 9 | 9, 2, 1; 10 | 10, 2, 1; ...
Links
- Paolo Xausa, Table of n, a(n) for n = 0..11724 (rows 0..3000 of triangle, flattened).
Programs
-
Mathematica
A381962row[n_] := NestWhileList[DigitSum[#, 2] &, n, # > 1 &]; Array[A381962row, 30, 0]
-
Python
def row(n): out = [n] if n > 1 else [] while (n:=n.bit_count()) > 1: out += [n] return out + [n] print([e for n in range(27) for e in row(n)]) # Michael S. Branicky, Mar 12 2025