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.

A330091 Inverse permutation to A329303.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 10, 9, 12, 13, 14, 15, 16, 23, 22, 19, 18, 21, 20, 17, 24, 27, 26, 25, 28, 29, 30, 31, 32, 47, 46, 39, 38, 45, 44, 35, 34, 41, 42, 37, 36, 43, 40, 33, 48, 55, 54, 51, 50, 53, 52, 49, 56, 59, 58, 57, 60, 61, 62, 63, 64, 95, 94, 79
Offset: 0

Views

Author

Rémy Sigrist, Dec 01 2019

Keywords

Comments

If the run lengths in binary expansion of n are (r(1), ..., r(w)), then the run lengths in binary expansion of a(n) are (r(1), r(w), r(2), r(w-1), ...); this corresponds to a "milk shuffle".

Examples

			A329303(43) = 45, hence a(45) = 43.
		

Crossrefs

Cf. A329303.

Programs

  • PARI
    torl(n) = { my (rr=[]); while (n, my (r=valuation(n+(n%2),2)); rr = concat(r, rr); n\=2^r); rr }
    unshuffle(v) = { my (w=vector(#v), o=0, e=#v+1); for (k=1, #v, w[k]=v[if (k%2, o++, e--)]); w }
    fromrl(rr) = { my (v=0); for (k=1, #rr, v = (v+(k%2))*2^rr[k]-(k%2)); v }
    a(n) = fromrl(unshuffle(torl(n)))