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.

Showing 1-2 of 2 results.

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

Original entry on oeis.org

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
Offset: 0

Views

Author

Rémy Sigrist, Dec 01 2019

Keywords

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.

Examples

			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.
		

Crossrefs

See A329303 for a similar sequence.
Cf. A003558, A194959, A330090 (inverse).

Programs

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

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

A339132 Milk shuffle of the binary representation of n.

Original entry on oeis.org

0, 1, 2, 3, 2, 3, 6, 7, 2, 3, 6, 7, 10, 11, 14, 15, 2, 3, 6, 7, 18, 19, 22, 23, 10, 11, 14, 15, 26, 27, 30, 31, 2, 3, 6, 7, 18, 19, 22, 23, 34, 35, 38, 39, 50, 51, 54, 55, 10, 11, 14, 15, 26, 27, 30, 31, 42, 43, 46, 47, 58, 59, 62, 63, 2, 3, 6, 7, 18, 19, 22, 23
Offset: 0

Views

Author

Sander G. Huisman, Nov 24 2020

Keywords

Examples

			For n = 19 we take the binary representation without leading zeros: 10011.
We now shuffle the binary digits around according to A209279, which can be interpreted as a so-called milk shuffle.
For five digits the n-th digits gets moved around as follows: 1,2,3,4,5 => 3,2,4,1,5.
This reshuffling can be thought of taking the middle number, and then alternatingly taking digits from the left and then the right until all digits are taken.
We now apply this reshuffling to our binary digits of 19: 00111.
This is now reinterpreted into a decimal number: 7.
		

Crossrefs

Cf. A330090 (shuffle bits low to high).
Cf. A209279 (1-based shuffle), A332104 (0-based shuffle).

Programs

  • Mathematica
    milk[list_]:=Table[list[[{i,-i}]],{i,Length[list]/2}]//milkPost[#,list]&//Reverse//Flatten
    milkPost[x_,list_]:=x/;EvenQ[Length[list]]
    milkPost[x_,list_]:=Join[x,{list[[(Length[list]+1)/2]]}]
    Table[FromDigits[milk@IntegerDigits[i,2],2],{i,0,500}]
    (*OR*)
    Table[FromDigits[ResourceFunction["Shuffle"][IntegerDigits[i,2],"Milk"],2], {i,0,500}]
Showing 1-2 of 2 results.