A367306 Move bits in blocks in binary expansion of n where blocks are defined in Comments.
0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 9, 11, 12, 13, 14, 15, 16, 20, 17, 21, 18, 19, 22, 23, 24, 26, 25, 27, 28, 29, 30, 31, 32, 40, 33, 41, 34, 35, 42, 43, 36, 37, 38, 39, 44, 45, 46, 47, 48, 52, 49, 53, 50, 51, 54, 55, 56, 58, 57, 59, 60, 61, 62, 63, 64, 80, 65, 81
Offset: 0
Examples
For n = 45986, moves are in each (...) block n = 45986 = binary 1(01)1(001)11(010)(0010) a(n) = 46481 = binary 1(01)1(010)11(001)(0001) We have moves in last 3 blocks, while in the first block the rightmost 1 bit is already lies on the position after leftmost bit in block, so we have no change in this case.
Programs
-
PARI
a(n) = my(v1); v1 = binary(n); my(A = 1); while(A <= #v1, while(A <= #v1 && v1[A], A++); my(B = A); while((A + 1) <= #v1 && !v1[A + 1], A++); if(A < #v1, if((A + 2) <= #v1 && !v1[A + 2], B = A; A++); v1[A + 1] = !v1[A + 1]; v1[B + 1] = !v1[B + 1]); A += 2); fromdigits(v1, 2)
Comments