OFFSET
0,2
COMMENTS
EXAMPLE
The a(4)=19 subset sums are (0,4), (4,4), (0,31), (1,31), (3,31), (4,31), (0,22), (2,22), (4,22), (0,211), (1,211), (2,211), (3,211), (4,211), (0,1111), (1,1111), (2,1111), (3,1111), (4,1111).
MAPLE
b:= proc(n, i, s) option remember; `if`(n=0, nops(s),
`if`(i<1, 0, b(n, i-1, s)+b(n-i, min(n-i, i),
map(x-> [x, x+i][], s))))
end:
a:= n-> b(n$2, {0}):
seq(a(n), n=0..40); # Alois P. Heinz, May 18 2018
MATHEMATICA
Table[Total[Length[Union[Total/@Subsets[#]]]&/@IntegerPartitions[n]], {n, 15}]
(* Second program: *)
b[n_, i_, s_] := b[n, i, s] = If[n == 0, Length[s],
If[i < 1, 0, b[n, i - 1, s] + b[n - i, Min[n - i, i],
{#, # + i}& /@ s // Flatten // Union]]];
a[n_] := b[n, n, {0}];
a /@ Range[0, 40] (* Jean-François Alcover, May 20 2021, after Alois P. Heinz *)
PROG
CROSSREFS
KEYWORD
nonn
AUTHOR
Gus Wiseman, May 18 2018
STATUS
approved