A336771 Total sum of the left-to-right maxima in all compositions of n into distinct parts.
0, 1, 2, 8, 11, 22, 53, 75, 123, 193, 418, 538, 894, 1268, 1950, 3567, 4799, 7143, 10355, 14968, 20701, 36398, 46420, 69071, 94972, 136385, 182522, 259104, 402405, 527090, 741569, 1015491, 1397661, 1880541, 2567202, 3392612, 5153156, 6553844, 9088372, 12040797
Offset: 0
Keywords
Examples
a(6) = 53 = 6+4+5+5+3+3+6+4+6+5+6: (1)(2)(3), (1)(3)2, (2)1(3), (2)(3)1, (3)12, (3)21, (2)(4), (4)2, (1)(5), (5)1, (6).
Links
- Alois P. Heinz, Table of n, a(n) for n = 0..1000
Programs
-
Maple
b:= proc(n, i, k, m) option remember; `if`(i
(2*i-k+1)*k/2, 0, `if`(n=0, [1, 0], b(n, i-1, k, m)+ (p-> p+[0, p[1]*i/(m+1-k)])(b(n-i, min(n-i, i-1), k-1, m)))) end: a:= n-> add(b(n$2, k$2)[2]*k!, k=1..floor((sqrt(8*n+1)-1)/2)): seq(a(n), n=0..40); -
Mathematica
b[n_, i_, k_, m_] := b[n, i, k, m] = If[i < k || n > (2*i - k + 1)*k/2, {0, 0}, If[n == 0, {1, 0}, b[n, i - 1, k, m] + Function[p, p+{0, p[[1]]*i/(m+1-k)}][b[n-i, Min[n-i, i-1], k-1, m]]]]; a[n_] := Sum[b[n, n, k, k][[2]]*k!, {k, 1, Floor[(Sqrt[8*n + 1] - 1)/2]}]; Table[a[n], {n, 0, 40}] (* Jean-François Alcover, Jul 12 2021, after Alois P. Heinz *)