OFFSET
0,6
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..1000
EXAMPLE
a(6) = 6: partitions of 6 into an odd number of parts are [2,1,1,1,1], [2,2,2], [3,2,1], [4,1,1], [6], difference between sum of largest parts and sum of smallest parts is (2+2+3+4+6) - (1+2+1+1+6) = 17 - 11 = 6.
MAPLE
g:= proc(n, i) option remember; [`if`(n=i, n, 0), 0]+
`if`(i>n, [0, 0], g(n, i+1)+(l-> [l[2], l[1]])(g(n-i, i)))
end:
b:= proc(n, i) option remember;
[`if`(n=i, n, 0), 0]+`if`(i<1, [0, 0], b(n, i-1)+
`if`(n<i, [0, 0], (l-> [l[2], l[1]])(b(n-i, i))))
end:
a:= n-> g(n, 1)[1] -b(n, n)[1]:
seq(a(n), n=0..50);
MATHEMATICA
g[n_, i_] := g[n, i] = {If[n==i, n, 0], 0} + If[i>n, {0, 0}, g[n, i+1] + Reverse[g[n-i, i]]]; b[n_, i_] := b[n, i] = {If[n==i, n, 0], 0} + If[i<1, {0, 0}, b[n, i-1] + If[n<i, {0, 0}, Reverse[b[n-i, i]]]]; a[n_] := g[n, 1][[1]] - b[n, n][[1]]; Table[a[n], {n, 0, 50}] (* Jean-François Alcover, Feb 16 2017, translated from Maple *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Alois P. Heinz, Feb 12 2013
STATUS
approved