%I #22 Apr 13 2022 14:20:07
%S 0,1,2,6,8,15,30,42,64,99,190,242,384,533,798,1380,1824,2635,3762,
%T 5320,7280,12327,15554,22632,30720,43425,57538,80730,122920,159239,
%U 220830,299150,406656,542883,733278,962710,1443600,1820437,2496638,3280992,4451120
%N Sum of the leftmost parts in all compositions of n into distinct parts.
%C Also sum of the rightmost parts in all compositions of n into distinct parts.
%H Alois P. Heinz, <a href="/A336896/b336896.txt">Table of n, a(n) for n = 0..5000</a>
%F a(n) = n * Sum_{k=1..floor((sqrt(8*n+1)-1)/2)} (k-1)! * A008289(n,k).
%F a(n) = n * A032153(n).
%e a(6) = 30 = 1 + 1 + 2 + 2 + 3 + 3 + 2 + 4 + 1 + 5 + 6: (1)23, (1)32, (2)13, (2)31, (3)12, (3)21, (2)4, (4)2, (1)5, (5)1, (6).
%p b:= proc(n, i, p) option remember; `if`(i*(i+1)/2<n, 0,
%p `if`(n=0, p!, b(n, i-1, p)+b(n-i, min(n-i, i-1), p+1)))
%p end:
%p a:= n-> `if`(n=0, 0, n*b(n$2, -1)):
%p seq(a(n), n=0..50);
%t b[n_, i_, p_] := b[n, i, p] = If[i*(i + 1)/2 < n, 0,
%t If[n == 0, p!, b[n, i - 1, p] + b[n - i, Min[n - i, i - 1], p + 1]]];
%t a[n_] := If[n == 0, 0, n*b[n, n, -1]];
%t Table[a[n], {n, 0, 50}] (* _Jean-François Alcover_, Apr 13 2022, after _Alois P. Heinz_ *)
%Y Cf. A000225 (the same for all compositions), A008289, A032020, A032153.
%K nonn
%O 0,3
%A _Alois P. Heinz_, Aug 07 2020