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!)
A266151 Take the binary representation of n, increase each run of 1's by one 1 if the length of run is odd, otherwise, if length of run is even, remove one 1. a(n) is the decimal equivalent of the result. 3
0, 3, 6, 1, 12, 27, 2, 15, 24, 51, 54, 13, 4, 11, 30, 7, 48, 99, 102, 25, 108, 219, 26, 111, 8, 19, 22, 5, 60, 123, 14, 63, 96, 195, 198, 49, 204, 411, 50, 207, 216, 435, 438, 109, 52, 107, 222, 55, 16, 35, 38, 9, 44, 91, 10, 47, 120, 243, 246, 61, 28, 59, 126, 31 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,2
COMMENTS
This is a self-inverse permutation of the positive integers.
LINKS
EXAMPLE
a(4) = 12 since 4 = 100 binary -> 1100 = 12 decimal,
a(5) = 27 since 5 = 101 binary -> 110011 = 27 decimal,
a(6) = 2 since 6 = 110 binary -> 10 = 2 decimal.
MATHEMATICA
Table[FromDigits[#, 2] &@ Flatten[If[First@ # == 1, If[OddQ@ Length@ #, Append[IntegerDigits@ #, 1], Most@ IntegerDigits@ #], #] & /@ Split@ IntegerDigits[n, 2]], {n, 63}] (* Michael De Vlieger, Dec 22 2015 *)
PROG
(PARI) a(n) = if (n==0, 0, my (b=n%2, r=valuation(n+b, 2), rr=if (b==0, r, r%2, r+1, r-1)); (a(n\2^r)+b)*2^rr-b) \\ Rémy Sigrist, Jan 20 2019
CROSSREFS
Sequence in context: A209144 A130724 A120229 * A192100 A123534 A100960
KEYWORD
nonn,base
AUTHOR
Alex Ratushnyak, Dec 21 2015
EXTENSIONS
a(0) = 0 prepended by Rémy Sigrist, Jan 20 2019
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 April 19 11:14 EDT 2024. Contains 371791 sequences. (Running on oeis4.)