login
A367306
Move bits in blocks in binary expansion of n where blocks are defined in Comments.
1
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,3
COMMENTS
Define the "blocks" of the binary expansion of n as runs of 0's followed by a 1 bit and additionally followed with a 0 bit if it lies immediately after the 1 bit. For example, the blocks in 45986 (shown in parentheses) are 1(01)1(001)11(010)(0010). To obtain binary expansion of a(n) from binary expansion of n, move the rightmost bit in each block to the position after leftmost bit in the same block and leave all other 1 bits unchanged (see the Example).
FORMULA
a(n) < 2^k iff n < 2^k for k >= 0.
Conjecture: a(n) = A200714(p(n) + 1) where p(n) is an inverse permutation to A358654.
EXAMPLE
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.
PROG
(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)
CROSSREFS
Sequence in context: A353907 A363271 A031044 * A194978 A195096 A194977
KEYWORD
nonn,base
AUTHOR
Mikhail Kurkov, Nov 13 2023
STATUS
approved