A317329 Number of permutations of [n] with equal lengths of increasing runs.
1, 2, 2, 7, 2, 82, 2, 1456, 1515, 50774, 2, 3052874, 2, 199364414, 136835794, 19451901825, 2, 2510158074714, 2, 370671075758054, 132705620239756, 69348874393843334, 2, 15772160279898993782, 613498040952503, 4087072509293134292962, 705927677748508225534
Offset: 1
Keywords
Examples
a(4) = 7: 1234, 1324, 1423, 2314, 2413, 3412, 4321.
Links
- Alois P. Heinz, Table of n, a(n) for n = 1..400
Programs
-
Maple
b:= proc(u, o, t, d) option remember; `if`(u+o=0, 1, `if`(t=d, add(b(u-j, o+j-1, 1, d), j=1..u), add(b(u+j-1, o-j, t+1, d), j=1..o))) end: a:= proc(n) option remember; `if`(n=1, 1, 2+add( b(n, 0, d$2), d=numtheory[divisors](n) minus {1, n})) end: seq(a(n), n=1..35);
-
Mathematica
b[u_, o_, t_, d_] := b[u, o, t, d] = If[u + o == 0, 1, If[t == d, Sum[b[u - j, o + j - 1, 1, d], {j, 1, u}], Sum[b[u + j - 1, o - j, t + 1, d], {j, 1, o}]]]; a[n_] := a[n] = If[n == 1, 1, 2 + Sum[b[n, 0, d, d], {d, Divisors[n] ~Complement~ {1, n}}]]; Array[a, 35] (* Jean-François Alcover, Aug 01 2021, after Alois P. Heinz *)
Formula
a(n) = 2 <=> n in { A000040 }.