OFFSET
0,4
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..20000
FORMULA
a(2^n) = 1.
a(2^n-1) = 2^n-1.
a(2n) = a(n), a(2n+1) = a(n) + n+1, a(0) = 0. - Alois P. Heinz, Nov 19 2015
EXAMPLE
S_0 = [0], a(0) = 0;
S_1 = [0, 1], a(1) = 1;
S_2 = [0, 01, 1], a(2) = 1;
S_3 = [0, 01, 1, 11], a(3) = 3;
S_4 = [0, 001, 01, 1, 11], a(4) = 1;
S_5 = [0, 001, 01, 1, 101, 11], a(5) = 4;
S_6 = [0, 001, 01, 011, 1, 101, 11], a(6) = 3;
S_7 = [0, 001, 01, 011, 1, 101, 11, 111], a(7) = 7;
S_8 = [0, 0001, 001, 01, 011, 1, 101, 11, 111], a(8) = 1;
...
MAPLE
a:= proc(n) option remember; `if`(n=0, 0,
`if`(irem(n, 2, 'r')=0, a(r), a(r)+r+1))
end:
seq(a(n), n=0..100); # Alois P. Heinz, Nov 19 2015
MATHEMATICA
A264596[0]=0; A264596[n_]:=A264596[n]=A264596[Floor[n/2]]+Boole[OddQ[n]](Floor[n/2]+1); Array[A264596, 100, 0] (* Paolo Xausa, Nov 04 2023, after Alois P. Heinz *)
PROG
(Python)
def A264596(n):
return sorted(format(i, 'b')[::-1] for i in range(n+1)).index(format(n, 'b')[::-1]) # Chai Wah Wu, Nov 22 2015
CROSSREFS
KEYWORD
nonn,base
AUTHOR
N. J. A. Sloane, Nov 19 2015
EXTENSIONS
More terms from Alois P. Heinz, Nov 19 2015
STATUS
approved