A343934 Irregular triangle read by rows: row n gives the sequence of iterations of k - A006519(k), starting with k=n, until 0 is reached.
1, 2, 3, 2, 4, 5, 4, 6, 4, 7, 6, 4, 8, 9, 8, 10, 8, 11, 10, 8, 12, 8, 13, 12, 8, 14, 12, 8, 15, 14, 12, 8, 16, 17, 16, 18, 16, 19, 18, 16, 20, 16, 21, 20, 16, 22, 20, 16, 23, 22, 20, 16, 24, 16, 25, 24, 16, 26, 24, 16, 27, 26, 24, 16, 28, 24, 16
Offset: 1
Examples
The triangle begins 1 2 3 2 4 5 4 6 4 7 6 4
Links
- Peter Kagey, Rows n = 1..1023, flattened
Programs
-
Mathematica
Table[Most @ NestWhileList[# - 2^IntegerExponent[#, 2] &, n, # > 0 &], {n, 1, 30}] // Flatten (* Amiram Eldar, May 05 2021 *)
-
Python
def gen_a(): for n in range(1,100): k = n while k>0: yield k k = k & (k-1) a = gen_a()
Comments