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-4 of 4 results.

A330090 Inverse permutation to A330081.

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Dec 01 2019

Keywords

Comments

If the binary expansion of n is (b(1), ..., b(w)), then the binary expansion of a(n) is (b(1), b(w), b(2), b(w-1), ...); this corresponds to a "milk shuffle".

Examples

			A330081(19) = 22, hence a(22) = 19.
		

Crossrefs

Cf. A330081.

Programs

  • PARI
    unshuffle(v) = { my (w=vector(#v), o=0, e=#v+1); for (k=1, #v, w[k]=v[if (k%2, o++, e--)]); w }
    a(n) = fromdigits(unshuffle(binary(n)), 2)

A194959 Fractalization of (1 + floor(n/2)).

Original entry on oeis.org

1, 1, 2, 1, 3, 2, 1, 3, 4, 2, 1, 3, 5, 4, 2, 1, 3, 5, 6, 4, 2, 1, 3, 5, 7, 6, 4, 2, 1, 3, 5, 7, 8, 6, 4, 2, 1, 3, 5, 7, 9, 8, 6, 4, 2, 1, 3, 5, 7, 9, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 12, 10, 8, 6, 4, 2, 1, 3, 5
Offset: 1

Views

Author

Clark Kimberling, Sep 06 2011

Keywords

Comments

Suppose that p(1), p(2), p(3), ... is an integer sequence satisfying 1 <= p(n) <= n for n >= 1. Define g(1)=(1) and for n > 1, form g(n) from g(n-1) by inserting n so that its position in the resulting n-tuple is p(n). The sequence f obtained by concatenating g(1), g(2), g(3), ... is clearly a fractal sequence, here introduced as the fractalization of p. The interspersion associated with f is here introduced as the interspersion fractally induced by p, denoted by I(p); thus, the k-th term in the n-th row of I(p) is the position of the k-th n in f. Regarded as a sequence, I(p) is a permutation of the positive integers; its inverse permutation is denoted by Q(p).
...
Example: Let p=(1,2,2,3,3,4,4,5,5,6,6,7,7,...)=A008619. Then g(1)=(1), g(2)=(1,2), g(3)=(1,3,2), so that
f=(1,1,2,1,3,2,1,3,4,2,1,3,5,4,2,1,3,5,6,4,2,1,...)=A194959; and I(p)=A057027, Q(p)=A064578.
The interspersion I(P) has the following northwest corner, easily read from f:
1 2 4 7 11 16 22
3 6 10 15 21 28 36
5 8 12 17 23 30 38
9 14 20 27 35 44 54
...
Following is a chart of selected p, f, I(p), and Q(p):
p f I(p) Q(p)
Count odd numbers up to n, then even numbers down from n. - Franklin T. Adams-Watters, Jan 21 2012
This sequence defines the square array A(n,k), n > 0 and k > 0, read by antidiagonals and the triangle T(n,k) = A(n+1-k,k) for 1 <= k <= n read by rows (see Formula and Example). - Werner Schulte, May 27 2018

Examples

			The sequence p=A008619 begins with 1,2,2,3,3,4,4,5,5,..., so that g(1)=(1). To form g(2), write g(1) and append 2 so that in g(2) this 2 has position p(2)=2: g(2)=(1,2). Then form g(3) by inserting 3 at position p(3)=2: g(3)=(1,3,2), and so on. The fractal sequence A194959 is formed as the concatenation g(1)g(2)g(3)g(4)g(5)...=(1,1,2,1,3,2,1,3,4,2,1,3,5,4,2,...).
From _Werner Schulte_, May 27 2018: (Start)
This sequence seen as a square array read by antidiagonals:
  n\k: 1  2  3  4  5   6   7   8   9  10  11  12 ...
  ===================================================
   1   1  2  2  2  2   2   2   2   2   2   2   2 ... (see A040000)
   2   1  3  4  4  4   4   4   4   4   4   4   4 ... (see A113311)
   3   1  3  5  6  6   6   6   6   6   6   6   6 ...
   4   1  3  5  7  8   8   8   8   8   8   8   8 ...
   5   1  3  5  7  9  10  10  10  10  10  10  10 ...
   6   1  3  5  7  9  11  12  12  12  12  12  12 ...
   7   1  3  5  7  9  11  13  14  14  14  14  14 ...
   8   1  3  5  7  9  11  13  15  16  16  16  16 ...
   9   1  3  5  7  9  11  13  15  17  18  18  18 ...
  10   1  3  5  7  9  11  13  15  17  19  20  20 ...
  etc.
This sequence seen as a triangle read by rows:
  n\k:  1  2  3  4  5   6   7   8   9  10  11  12  ...
  ======================================================
   1    1
   2    1  2
   3    1  3  2
   4    1  3  4  2
   5    1  3  5  4  2
   6    1  3  5  6  4   2
   7    1  3  5  7  6   4   2
   8    1  3  5  7  8   6   4   2
   9    1  3  5  7  9   8   6   4   2
  10    1  3  5  7  9  10   8   6   4   2
  11    1  3  5  7  9  11  10   8   6   4   2
  12    1  3  5  7  9  11  12  10   8   6   4   2
  etc.
(End)
		

References

  • Clark Kimberling, "Fractal sequences and interspersions," Ars Combinatoria 45 (1997) 157-168.

Crossrefs

Cf. A000142, A000217, A005408, A005843, A008619, A057027, A064578, A209229, A210535, A219977; A000012 (col 1), A157532 (col 2), A040000 (row 1), A113311 (row 2); A194029 (introduces the natural fractal sequence and natural interspersion of a sequence - different from those introduced at A194959).
Cf. A003558 (g permutation order), A102417 (index), A330081 (on bits), A057058 (inverse).

Programs

  • Mathematica
    r = 2; p[n_] := 1 + Floor[n/r]
    Table[p[n], {n, 1, 90}]  (* A008619 *)
    g[1] = {1}; g[n_] := Insert[g[n - 1], n, p[n]]
    f[1] = g[1]; f[n_] := Join[f[n - 1], g[n]]
    f[20] (* A194959 *)
    row[n_] := Position[f[30], n];
    u = TableForm[Table[row[n], {n, 1, 5}]]
    v[n_, k_] := Part[row[n], k];
    w = Flatten[Table[v[k, n - k + 1], {n, 1, 13},
    {k, 1, n}]]  (* A057027 *)
    q[n_] := Position[w, n]; Flatten[
    Table[q[n], {n, 1, 80}]]  (* A064578 *)
    Flatten[FoldList[Insert[#1, #2, Floor[#2/2] + 1] &, {}, Range[10]]] (* Birkas Gyorgy, Jun 30 2012 *)
  • PARI
    T(n,k) = min(k<<1-1,(n-k+1)<<1); \\ Kevin Ryde, Oct 09 2020

Formula

From Werner Schulte, May 27 2018 and Jul 10 2018: (Start)
Seen as a triangle: It seems that the triangle T(n,k) for 1 <= k <= n (see Example) is the mirror image of A210535.
Seen as a square array A(n,k) and as a triangle T(n,k):
A(n,k) = 2*k-1 for 1 <= k <= n, and A(n,k) = 2*n for 1 <= n < k.
A(n+1,k+1) = A(n,k+1) + A(n,k) - A(n-1,k) for k > 0 and n > 1.
A(n,k) = A(k,n) - 1 for n > k >= 1.
P(n,x) = Sum_{k>0} A(n,k)*x^(k-1) = (1-x^n)*(1-x^2)/(1-x)^3 for n >= 1.
Q(y,k) = Sum_{n>0} A(n,k)*y^(n-1) = 1/(1-y) for k = 1 and Q(y,k) = Q(y,1) + P(k-1,y) for k > 1.
G.f.: Sum_{n>0, k>0} A(n,k)*x^(k-1)*y^(n-1) = (1+x)/((1-x)*(1-y)*(1-x*y)).
Sum_{k=1..n} A(n+1-k,k) = Sum_{k=1..n} T(n,k) = A000217(n) for n > 0.
Sum_{k=1..n} (-1)^(k-1) * A(n+1-k,k) = Sum_{k=1..n} (-1)^(k-1) * T(n,k) = A219977(n-1) for n > 0.
Product_{k=1..n} A(n+1-k,k) = Product_{k=1..n} T(n,k) = A000142(n) for n > 0.
A(n+m,n) = A005408(n-1) for n > 0 and some fixed m >= 0.
A(n,n+m) = A005843(n) for n > 0 and some fixed m > 0.
Let A_m be the upper left part of the square array A(n,k) with m rows and m columns. Then det(A_m) = 1 for some fixed m > 0.
The P(n,x) satisfy the recurrence equation P(n+1,x) = P(n,x) + x^n*P(1,x) for n > 0 and initial value P(1,x) = (1+x)/(1-x).
Let B(n,k) be multiplicative with B(n,p^e) = A(n,e+1) for e >= 0 and some fixed n > 0. That yields the Dirichlet g.f.: Sum_{k>0} B(n,k)/k^s = (zeta(s))^3/(zeta(2*s)*zeta(n*s)).
Sum_{k=1..n} A(k,n+1-k)*A209229(k) = 2*n-1. (conjectured)
(End)
From Kevin Ryde, Oct 09 2020: (Start)
T(n,k) = 2*k-1 if 2*k-1 <= n, or 2*(n+1-k) if 2*k-1 > n. [Lévy, chapter 1 section 1 equations (a),(b)]
Fixed points T(n,k)=k for k=1 and k = (2/3)*(n+1) when an integer. [Lévy, chapter 1 section 2 equation (3)]
(End)

Extensions

Name corrected by Franklin T. Adams-Watters, Jan 21 2012

A333776 Scan the binary representation of n from right to left; at each 1, reverse the bits to the right and excluding this 1. The resulting binary representation is that of a(n).

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Apr 05 2020

Keywords

Comments

This sequence is a permutation of the nonnegative integers (as it is injective and preserves the binary length); see A333777 for the inverse.
We can devise a variant of this sequence for any fixed base b > 1, by performing a reversal at each nonzero digit in base b.

Examples

			For n = 90:
- the binary representation of 90 is "1011010",
- this binary representation evolves as follows (parentheses indicate reversals):
    1 0 1 1 0 1(0)
    1 0 1 1(0 1 0)
    1 0 1(0 1 0 1)
    1(1 0 1 0 1 0)
- the resulting binary representation is "1101010"
- and a(90) = 106.
The binary plot of the first terms is as follows (#'s denote 1's):
                                  ################################
                  ################ # #  ##    ####        ########
          ######## # #  ##    ####  ## # #  ## # #    #### # #  ##
      #### # #  ##  ## # #  ## # #    #### # #  ##  ## # #  ## # #
    ## # #  ## # #    #### # #  ##        ######## # #  ##    ####
   # #  ##    ####        ########                ################
            1         2         3         4         5         6
  0123456789012345678901234567890123456789012345678901234567890123
		

Crossrefs

See A333692 for a similar sequence.
Cf. A000120, A330081, A333777 (inverse), A333778 (fixed points).

Programs

  • PARI
    a(n, base=2) = { my (d=digits(n, base), t=[]); forstep (k=#d, 1, -1, if (d[k], t=Vecrev(t)); t=concat(d[k], t)); fromdigits(t, base); }

Formula

a(2*n) <= 2*a(n) with equality iff n = 0 or n is a power of 2.
A000120(a(n)) = A000120(n).

A329303 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(3), r(5), ..., r(6), r(4), r(2)).

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 10, 9, 12, 13, 14, 15, 16, 23, 20, 19, 22, 21, 18, 17, 24, 27, 26, 25, 28, 29, 30, 31, 32, 47, 40, 39, 44, 43, 36, 35, 46, 41, 42, 45, 38, 37, 34, 33, 48, 55, 52, 51, 54, 53, 50, 49, 56, 59, 58, 57, 60, 61, 62, 63, 64, 95, 80, 79
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 number of runs. See A330091 for the inverse.

Examples

			For n = 19999:
- the binary representation of 19999 is "100111000011111",
- the corresponding run lengths are (1, 2, 3, 4, 5),
- hence the run lengths of a(n) are (1, 3, 5, 4, 2),
- and its binary representation is "100011111000011",
- so a(n) = 18371.
		

Crossrefs

See A330081 for a similar sequence.
Cf. A003558, A194959, A330091 (inverse).

Programs

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

Formula

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