A233932 Irregular table read by rows: T(n,k) is the binary representation of n shifted right k times and incremented if the last bit shifted away was set.
1, 1, 1, 2, 1, 2, 1, 1, 3, 1, 1, 3, 2, 1, 4, 2, 1, 4, 2, 1, 1, 5, 2, 1, 1, 5, 3, 1, 1, 6, 3, 1, 1, 6, 3, 2, 1, 7, 3, 2, 1, 7, 4, 2, 1, 8, 4, 2, 1, 8, 4, 2, 1, 1, 9, 4, 2, 1, 1, 9, 5, 2, 1, 1, 10, 5, 2, 1, 1, 10, 5, 3, 1, 1, 11, 5, 3, 1, 1, 11, 6, 3, 1, 1, 12, 6, 3, 1, 1, 12, 6, 3, 2, 1, 13, 6, 3, 2, 1, 13, 7, 3, 2, 1, 14, 7
Offset: 1
Examples
22 in binary is 10110, so the row length is 5. T(22, 1) = 11, T(22, 2) = 5 + 1 = 6, T(22, 3) = 2 + 1 = 3, T(22, 4) = 1, T(22, 5) = 0 + 1. So the 22nd row reads 11, 6, 3, 1, 1. Table starts: 1; 1, 1; 2, 1; 2, 1, 1; 3, 1, 1; 3, 2, 1; 4, 2, 1; 4, 2, 1, 1; 5, 2, 1, 1; 5, 3, 1, 1; ...
Programs
-
PARI
T(n,k)=b=binary(n);n\2^k+b[#b-k+1]
-
PARI
row(n) = my(b=binary(n)); vector(#b, k, n\2^k+b[#b-k+1]); \\ Michel Marcus, Sep 03 2019
Formula
T(n,k) = round(n/2^k), 1 <= k <= floor(log_2(n)) + 1, where round(1/2)=1. - Ridouane Oudra, Sep 02 2019
Comments