A092569 Permutation of integers a(a(n)) = n. In binary representation of n, transformation of inner bits, 1 <-> 0, gives binary representation of a(n).
0, 1, 2, 3, 6, 7, 4, 5, 14, 15, 12, 13, 10, 11, 8, 9, 30, 31, 28, 29, 26, 27, 24, 25, 22, 23, 20, 21, 18, 19, 16, 17, 62, 63, 60, 61, 58, 59, 56, 57, 54, 55, 52, 53, 50, 51, 48, 49, 46, 47, 44, 45, 42, 43, 40, 41, 38, 39, 36, 37, 34, 35, 32, 33, 126, 127, 124, 125, 122, 123, 120
Offset: 0
Examples
a(9)=15 because 9_10 = 1001_2, transformation of inner bits gives 1001_2 -> 1111_2 = 15_10.
Links
- Michael De Vlieger, Table of n, a(n) for n = 0..10000
Crossrefs
Cf. A092570.
Programs
-
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 *)
-
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
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
Comments