A336434 Square array read by descending antidiagonals T(n,k): In the binary expansion of n, reverse the order of the bits in the same position as the active bits in A057716(k).
2, 4, 1, 1, 2, 3, 4, 4, 6, 4, 8, 2, 5, 1, 6, 1, 2, 6, 2, 5, 5, 8, 8, 10, 1, 3, 3, 7, 1, 2, 9, 4, 5, 6, 7, 8, 8, 2, 10, 4, 12, 3, 7, 8, 10, 1, 2, 3, 4, 5, 6, 7, 8, 12, 9, 8, 8, 10, 8, 12, 12, 14, 8, 9, 10, 11, 16, 4, 9, 4, 9, 6, 13, 1, 12, 12, 14, 12
Offset: 1
Examples
The binary expansion of 18 is 10010_2 and the active bits in the binary expansion of A057716(22) = 27 = 11011_2 are 0, 1, 3, and 4. So, to get T(18,22), we swap the 0th and 4th bits and then the 1st and 3rd bits, which gives us T(18,22) = 9. Square array T(n,k) begins: \k 1 2 3 4 5 6 7 8 9 10 ... n\ 1| 2 4 1 4 8 1 8 1 8 1 ... 2| 1 2 4 2 2 8 2 2 2 8 ... 3| 3 6 5 6 10 9 10 3 10 9 ... 4| 4 1 2 1 4 4 4 8 4 4 ... 5| 6 5 3 5 12 5 12 9 12 5 ... 6| 5 3 6 3 6 12 6 10 6 12 ... 7| 7 7 7 7 14 13 14 11 14 13 ... 8| 8 8 8 8 1 2 1 4 1 2 ... 9| 10 12 9 12 9 3 9 5 9 3 ... 10| 9 10 12 10 3 10 3 6 3 10 ...
Links
- Davis Smith, Table of n, a(n) for n = 1..5050; the first 100 antidiagonals of the array
- S. E. Anderson, Bit Twiddling Hacks.
Crossrefs
Programs
-
PARI
A336434(n,k)={my(K=k+#binary(k+#binary(k)), P=select(Z->bittest(K,Z),[0..#binary(K)-1]), Q1=P[1..floor(#P/2)],Q2=Vecrev(P)[1..floor(#P/2)], Sum=vecsum(apply(p->if(bittest(n,Q1[p])!=bittest(n,Q2[p]), bitor(shift(1,Q1[p]),shift(1,Q2[p]))), [1..floor(#P/2)])));bitxor(n,Sum)}
Comments