login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 59th year, we have over 358,000 sequences, and we’ve crossed 10,300 citations (which often say “discovered thanks to the OEIS”).

Other ways to Give
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
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, 18, 28, 20, 24, 16, 63, 47, 55, 39, 59, 43, 51, 35, 61, 45, 53, 37, 57, 41, 49, 33, 62, 46, 54, 38, 58, 42, 50, 34, 60, 44, 52, 36, 56, 40, 48, 32, 127, 95, 111, 79, 119, 87, 103, 71 (list; graph; refs; listen; history; text; internal format)
OFFSET

1,2

COMMENTS

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

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

Fixed points union { 0 } are in A290254. - Alois P. Heinz, Aug 24 2017

LINKS

Harry J. Smith and Alois P. Heinz, Table of n, a(n) for n = 1..8191 (first 1024 terms from Harry J. Smith)

Index entries for sequences that are permutations of the natural numbers

FORMULA

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

A000120(a(n)) = A000120(A054429(n)) = A023416(n) + 1 (conjectured). - Ralf Stephan, Oct 05 2003

To verify first conjecture above we use n = Sum_{k=0..l(n)} T(n,k)*2^k where l(n) = floor(log_2(n)), T(n,k) = floor(n/2^k) mod 2, so by definition we have a(n) = Sum_{k=0..l(n)} (1-T(n,k-1))*2^(l(n)-k), then we use l(n) = l(floor(n/2)) + 1, T(2n,k) = T(n,k-1), T(2n+1,k) = T(n,k-1) + [k=0] and apply shifting of the summation. - Mikhail Kurkov, Nov 11 2019

EXAMPLE

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

MAPLE

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

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

r +2^i

end:

seq(a(n), n=1..100); # Alois P. Heinz, Feb 28 2015

MATHEMATICA

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 *)

PROG

(PARI)

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))

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

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))))

(PARI)

{ 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

(R)

maxrow <- 8 #by choice

a <- 1

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

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

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

}

a

# Yosu Yurramendi, Apr 05 2017

(Python)

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

print([a(n) for n in range(1, 51)]) # Indranil Ghosh, Aug 24 2017

(Python)

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

CROSSREFS

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

Cf. A000120, A023416, A290253, A290254.

Sequence in context: A286417 A303076 A298847 * A307544 A126314 A358139

Adjacent sequences: A059891 A059892 A059893 * A059895 A059896 A059897

KEYWORD

base,easy,nonn,look

AUTHOR

Marc LeBrun, Feb 06 2001

STATUS

approved

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 November 30 18:07 EST 2022. Contains 358453 sequences. (Running on oeis4.)