cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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, ... .

This page as a plain text file.
%I A059894 #97 Dec 08 2024 12:58:49
%S A059894 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 A059894 18,28,20,24,16,63,47,55,39,59,43,51,35,61,45,53,37,57,41,49,33,62,46,
%U A059894 54,38,58,42,50,34,60,44,52,36,56,40,48,32,127,95,111,79,119,87,103,71
%N 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, ... .
%C A059894 A self-inverse permutation. Also a(n) = A054429(A059893(n)) = A059893(A054429(n)).
%C A059894 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 A059894 Fixed points union { 0 } are in A290254. - _Alois P. Heinz_, Aug 24 2017
%H A059894 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 A059894 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%F A059894 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 A059894 A000120(a(n)) = A000120(A054429(n)) = A023416(n) + 1 (conjectured). - _Ralf Stephan_, Oct 05 2003
%e A059894 a(9) = a(1001_2) = 1011_2 = 11.
%p A059894 a:= proc(n) local i, m, r; m, r:= n, 0;
%p A059894       for i from 0 while m>1 do r:= 2*r +1 -irem(m,2,'m') od;
%p A059894       r +2^i
%p A059894     end:
%p A059894 seq(a(n), n=1..100);  # _Alois P. Heinz_, Feb 28 2015
%t A059894 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 A059894 (PARI) a(n)= my(b=binary(n)); 2^#b-1-fromdigits(Vecrev(b[2..#b]), 2); \\ _Ruud H.G. van Tol_, Nov 17 2024
%o A059894 (R)
%o A059894 maxrow <- 8 #by choice
%o A059894 a <- 1
%o A059894 for(m in 0:maxrow) for(k in 0:(2^m-1)){
%o A059894 a[2^(m+1) + 2*k    ] <- a[2^m + k] + 2^(m+1)
%o A059894 a[2^(m+1) + 2*k + 1] <- a[2^m + k] + 2^m
%o A059894 }
%o A059894 a
%o A059894 # _Yosu Yurramendi_, Apr 05 2017
%o A059894 (Python)
%o A059894 def a(n): return int('1' + ''.join('0' if i=='1' else '1' for i in bin(n)[3:])[::-1], 2)
%o A059894 print([a(n) for n in range(1, 51)]) # _Indranil Ghosh_, Aug 24 2017
%o A059894 (Python)
%o A059894 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 A059894 {A000027, A054429, A059893, A059894} form a 4-group.
%Y A059894 Cf. A000120, A023416, A290253, A290254.
%K A059894 base,easy,nonn,look
%O A059894 1,2
%A A059894 _Marc LeBrun_, Feb 06 2001