OFFSET
0,3
COMMENTS
To compute a(n): replace every other bit with zero (starting with the second bit) in each run of consecutive 1's in the binary expansion of n.
From Gus Wiseman, Jul 11 2025: (Start)
This is the greatest binary rank of a sparse subset of the binary indices of n, where:
1. The binary indices of a nonnegative integer are the positions of 1 in its reversed binary expansion.
2. A set is sparse iff 1 is not a first difference.
3. The binary rank of a set {S_1,S_2,...} is Sum_i 2^(S_i-1).
(End)
LINKS
FORMULA
EXAMPLE
The first terms, in decimal and in binary, are:
n a(n) bin(n) bin(a(n))
-- ---- ------ ---------
0 0 0 0
1 1 1 1
2 2 10 10
3 2 11 10
4 4 100 100
5 5 101 101
6 4 110 100
7 5 111 101
8 8 1000 1000
9 9 1001 1001
10 10 1010 1010
11 10 1011 1010
12 8 1100 1000
13 9 1101 1001
14 10 1110 1010
15 10 1111 1010
16 16 10000 10000
MATHEMATICA
bpe[n_]:=Join@@Position[Reverse[IntegerDigits[n, 2]], 1];
fbi[q_]:=If[q=={}, 0, Total[2^q]/2];
Table[Max@@fbi/@Select[Subsets[bpe[n]], FreeQ[Differences[#], 1]&], {n, 0, 100}] (* Gus Wiseman, Jul 11 2025 *)
PROG
(PARI) a(n) = { my (v = 0, e, x, y, b); while (n, x = y = 0; e = valuation(n, 2); for (k = 0, oo, if (bittest(n, e+k), n -= b = 2^(e+k); [x, y] = [y + b, x], v += x; break; ); ); ); return (v); }
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Jul 06 2024
STATUS
approved
