login
Sum of the squares of the number of parts in all partitions of n.
2

%I #29 Jun 06 2021 05:41:19

%S 0,1,5,14,34,68,133,232,402,652,1048,1609,2465,3640,5358,7694,10993,

%T 15399,21498,29520,40394,54572,73425,97756,129710,170525,223428,

%U 290552,376551,484819,622317,794167,1010515,1279376,1615126,2029948,2544600,3176856,3956277

%N Sum of the squares of the number of parts in all partitions of n.

%H Charles R Greathouse IV, <a href="/A296010/b296010.txt">Table of n, a(n) for n = 0..10000</a> (terms 0..115 from Robert G. Wilson v)

%F G.f.: Sum_{j>=1} j^2*x^j / Product_{i=1..j} (1-x^i). - _Alois P. Heinz_, Dec 02 2017

%e For n=4, the 5 partitions of 4 are 4, 3+1, 2+2, 2+1+1, and 1+1+1+1. These have 1, 2, 2, 3, and 4 parts, respectively. The sum of the squares is 1+4+4+9+16=34.

%p K:=[]:

%p for n from 0 to 20 do

%p co:=0:

%p for L in combinat[partition](n) do

%p co:=co+nops(L)^2:

%p od:

%p K:=[op(K),co]:

%p od:

%p K;

%p # second Maple program:

%p b:= proc(n, i, c) option remember; `if`(n=0 or i=1,

%p (n+c)^2, `if`(i>n, 0, b(n-i, i, c+1))+b(n, i-1, c))

%p end:

%p a:= n-> b(n$2, 0):

%p seq(a(n), n=0..50); # _Alois P. Heinz_, Dec 02 2017

%t f[n_] := Sum[i^2 (Length@ IntegerPartitions[n, {i}]), {i, n}]; Array[f, 34, 0] (* _Robert G. Wilson v_, Dec 02 2017 *)

%t b[n_, i_, c_] := b[n, i, c] = If[n == 0 || i == 1,

%t (n + c)^2, If[i > n, 0, b[n - i, i, c + 1]] + b[n, i - 1, c]];

%t a[n_] := b[n, n, 0];

%t a /@ Range[0, 50] (* _Jean-François Alcover_, Jun 06 2021, after _Alois P. Heinz_ *)

%o (PARI) first(n)=my(x='x+O('x^(n+1)),pr=1); concat(0,Vec(sum(j=1,n,pr*=1-x^j; j^2*x^j/pr))) \\ _Charles R Greathouse IV_, Dec 02 2017

%Y Cf. A006128, A008284, A036037.

%K nonn

%O 0,3

%A _Matthew C. Russell_, Dec 02 2017