The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A059894 Complement and reverse the order of all but the most significant bit in binary expansion of n. n = 1ab..yz -> 1ZY..BA = a(n), where A = 1-a, B = 1-b, ... . 26

%I #87 Apr 26 2024 06:08:19

%S 1,3,2,7,5,6,4,15,11,13,9,14,10,12,8,31,23,27,19,29,21,25,17,30,22,26,

%T 18,28,20,24,16,63,47,55,39,59,43,51,35,61,45,53,37,57,41,49,33,62,46,

%U 54,38,58,42,50,34,60,44,52,36,56,40,48,32,127,95,111,79,119,87,103,71

%N Complement and reverse the order of all but the most significant bit in binary expansion of n. n = 1ab..yz -> 1ZY..BA = a(n), where A = 1-a, B = 1-b, ... .

%C A self-inverse permutation. Also a(n) = A054429(A059893(n)) = A059893(A054429(n)).

%C a(n) is the viabin number of the integer partition that is conjugate to the integer partition with viabin number n. Example: a(9) = 11. Indeed, 9 and 11 are the viabin numbers of the conjugate partitions [2,1,1] and [3,1], respectively. For the definition of viabin number see comment in A290253. - _Emeric Deutsch_, Aug 23 2017

%C Fixed points union { 0 } are in A290254. - _Alois P. Heinz_, Aug 24 2017

%H Alois P. Heinz, <a href="/A059894/b059894.txt">Table of n, a(n) for n = 1..8191</a> (first 1024 terms from Harry J. Smith)

%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>

%F a(1) = 1, a(2n) = a(n) + 2^(floor(log_2(n))+1), a(2n+1) = a(n) + 2^floor(log_2(n)) (conjectured). - _Ralf Stephan_, Aug 21 2003

%F A000120(a(n)) = A000120(A054429(n)) = A023416(n) + 1 (conjectured). - _Ralf Stephan_, Oct 05 2003

%e a(9) = a(1001) = 1011 = 11.

%p a:= proc(n) local i, m, r; m, r:= n, 0;

%p for i from 0 while m>1 do r:= 2*r +1 -irem(m,2,'m') od;

%p r +2^i

%p end:

%p seq(a(n), n=1..100); # _Alois P. Heinz_, Feb 28 2015

%t Map[FromDigits[#, 2] &@ Flatten@ MapAt[Reverse, TakeDrop[IntegerDigits[#, 2], 1], -1] &, Flatten@ Table[Range[2^(n + 1) - 1, 2^n, -1], {n, 0, 6}]] (* _Michael De Vlieger_, Aug 23 2017 after _Harvey P. Dale_ at A054429 *)

%o (PARI)

%o a(n)=local(v, l); v=binary(n); l=length(v); 2^(l-1)+sum(k=0, l-2, if(!v[k+2], 2^k))

%o log2(n) = log(n)/log(2)

%o b(n)=if(n<2, 1, if(n%2==0, b(n/2)+2^(floor(log2(n/2))+1), b((n-1)/2)+2^floor(log2((n-1)/2))))

%o (PARI)

%o { for (n=1, 1024, a=1; b=n; while (b>1, a=2*a + 1 - 2*frac(b/2); b=floor(b/2); ); write("b059894.txt", n, " ", a); ) } \\ _Harry J. Smith_, Jun 30 2009

%o (R)

%o maxrow <- 8 #by choice

%o a <- 1

%o for(m in 0:maxrow) for(k in 0:(2^m-1)){

%o a[2^(m+1) + 2*k ] <- a[2^m + k] + 2^(m+1)

%o a[2^(m+1) + 2*k + 1] <- a[2^m + k] + 2^m

%o }

%o a

%o # _Yosu Yurramendi_, Apr 05 2017

%o (Python)

%o def a(n): return int('1' + ''.join('0' if i=='1' else '1' for i in bin(n)[3:])[::-1], 2)

%o print([a(n) for n in range(1, 51)]) # _Indranil Ghosh_, Aug 24 2017

%o (Python)

%o def A059894(n): return n if n <= 1 else -int((s:=bin(n)[-1:2:-1]),2)-1+2**(len(s)+1) # _Chai Wah Wu_, Feb 04 2022

%Y {A000027, A054429, A059893, A059894} form a 4-group.

%Y Cf. A000120, A023416, A290253, A290254.

%K base,easy,nonn,look

%O 1,2

%A _Marc LeBrun_, Feb 06 2001

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified May 14 10:34 EDT 2024. Contains 372532 sequences. (Running on oeis4.)