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.

A229551 Number of 1 up, 1 down, 2 up, 2 down, ... permutations of [n].

Original entry on oeis.org

1, 1, 1, 2, 5, 9, 40, 111, 643, 2261, 6176, 53560, 265001, 976535, 10699235, 65839306, 297528021, 1096638993, 16254932942, 131192702293, 760059358527, 3527632148650, 63700463354263, 620906514026512, 4309068955961383, 23776534616426566, 110660256825406666
Offset: 0

Views

Author

Alois P. Heinz, Oct 02 2013

Keywords

Examples

			a(2) = 1: 12.
a(3) = 2: 132, 231.
a(4) = 5: 1324, 1423, 2314, 2413, 3412.
a(5) = 9: 13245, 14235, 15234, 23145, 24135, 25134, 34125, 35124, 45123.
a(6) = 40: 132465, 132564, ..., 561342, 562341.
a(7) = 111: 1324765, 1325764, ..., 6724531, 6734521.
		

Crossrefs

Programs

  • Maple
    b:= proc(u, o, t, k) option remember; `if`(u+o=0, 1, `if`(t>0,
           add(b(u+j-1, o-j, `if`(t=k, [-1, k], [t+1, k])[]), j=1..o),
           add(b(u-j, o+j-1, `if`(t=-k, [1, k+1], [t-1, k])[]), j=1..u)))
        end:
    a:= n-> `if`(n=0, 1, add(b(j-1, n-j, 1, 1), j=1..n)):
    seq(a(n), n=0..35);
  • Mathematica
    b[u_, o_, t_, k_] := b[u, o, t, k] = If[u + o == 0, 1, If[t > 0, Sum[b[u + j - 1, o - j, If[t == k, -1, t + 1], k], {j, 1, o}], Sum[b[u - j, o + j - 1, If[t == -k, 1, t - 1], If[t == -k, k + 1, k]], {j, 1, u}]]];
    a[n_] := If[n == 0, 1, Sum[b[j - 1, n - j, 1, 1], {j, 1, n}]];
    Table[a[n], {n, 0, 35}] (* Jean-François Alcover, Jun 16 2018, after Alois P. Heinz *)