OFFSET
0,3
COMMENTS
LINKS
Michael De Vlieger, Table of n, a(n) for n = 0..10000
FORMULA
a(0) = 0, a(1) = 1, a(2) = 2, a(3) = 3, a(2^(m+1) +k) = a(2^m+k) + 2^(m+1),
a(2^(m+1)+2^m+k) = a(2^m+k) + 2^m, m >= 1, 0 <= k < 2^m. - Yosu Yurramendi, Apr 02 2017
EXAMPLE
a(9)=15 because 9_10 = 1001_2, transformation of inner bits gives 1001_2 -> 1111_2 = 15_10.
MATHEMATICA
bb={0, 1, 2, 3}; Do[id=IntegerDigits[n, 2]; Do[id[[i]]=1-id[[i]], {i, 2, Length[id]-1}]; bb=Append[bb, FromDigits[id, 2]], {n, 4, 1000}]; fla=Flatten[bb]
(* Second program: *)
Table[If[n < 2, n, Function[b, FromDigits[#, 2] &@ Join[{First@ b}, Most[Rest@ b] /. { 0 -> 1, 1 -> 0}, {Last@ b}]]@ IntegerDigits[n, 2]], {n, 0, 70}] (* Michael De Vlieger, Apr 03 2017 *)
PROG
(PARI)T(n)={pow2=2; v=binary(n); L=#v-1; forstep(k=L, 2, -1, if(v[k], n-=pow2, n+=pow2); pow2*=2); return(n)};
for(n=0, 70, print1(T(n), ", ")) \\ Washington Bomfim, Jan 18 2011
(R)
maxrow <- 8 # by choice
a <- 1:3 # If it were c(1, 3, 2), it would be A054429
for(m in 1:maxrow) for(k in 0:(2^m-1)){
a[2^(m+1)+ k] = a[2^m+k] + 2^(m+1)
a[2^(m+1)+2^m+k] = a[2^m+k] + 2^m
}
a
# Yosu Yurramendi, Apr 10 2017
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Zak Seidov, Feb 28 2004
STATUS
approved