login
The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A330081 If the binary expansion of n is (b(1), ..., b(w)), then the binary expansion of a(n) is (b(1), b(3), b(5), ..., b(6), b(4), b(2)). 5
0, 1, 2, 3, 4, 6, 5, 7, 8, 10, 12, 14, 9, 11, 13, 15, 16, 20, 18, 22, 24, 28, 26, 30, 17, 21, 19, 23, 25, 29, 27, 31, 32, 36, 40, 44, 34, 38, 42, 46, 48, 52, 56, 60, 50, 54, 58, 62, 33, 37, 41, 45, 35, 39, 43, 47, 49, 53, 57, 61, 51, 55, 59, 63, 64, 72, 68, 76 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,3

COMMENTS

This sequence is a permutation of the nonnegative integers that preserves the binary length as well as the Hamming weight. See A330090 for the inverse.

LINKS

Rémy Sigrist, Table of n, a(n) for n = 0..8192

Index entries for sequences related to binary expansion of n

Index entries for sequences that are permutations of the natural numbers

FORMULA

If n has w binary digits, then a^A003558(w-1)(n) = n (where a^k denotes the k-th iterate of the sequence).

EXAMPLE

For n = 1234:

- the binary expansion of 1234 is "10011010010",

- odd-indexed bits are "101100",

- even-indexed bits are "01001", and in reverse order "10010",

- hence the binary expansion of a(1234) is "10110010010",

- so a(1234) = 1426.

PROG

(PARI) shuffle(v) = { my (w=vector(#v), o=0, e=#v+1); for (k=1, #v, w[if (k%2, o++, e--)]=v[k]); w }

a(n) = fromdigits(shuffle(binary(n)), 2)

CROSSREFS

See A329303 for a similar sequence.

Cf. A003558, A194959, A330090 (inverse).

Sequence in context: A275119 A218252 A080541 * A072759 A257683 A343152

Adjacent sequences:  A330078 A330079 A330080 * A330082 A330083 A330084

KEYWORD

nonn,base,easy

AUTHOR

Rémy Sigrist, Dec 01 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 | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified September 24 03:26 EDT 2021. Contains 347623 sequences. (Running on oeis4.)