[go: up one dir, main page]

login
A331165
a(n) = a(n-1) + p(n) if p(n) > a(n-1), otherwise a(n) = a(n-1) - p(n), where p is the partition function A000041 (assuming a(n) = 0 for n < 0).
2
1, 0, 2, 5, 0, 7, 18, 3, 25, 55, 13, 69, 146, 45, 180, 4, 235, 532, 147, 637, 10, 802, 1804, 549, 2124, 166, 2602, 5612, 1894, 6459, 855, 7697, 16046, 5903, 18213, 3330, 21307, 42944, 16929, 48114, 10776, 55359, 2185, 65446, 140621, 51487, 157045, 32291, 179564
OFFSET
0,3
LINKS
MAPLE
a:= proc(n) option remember; `if`(n<0, 0, ((s, t)-> s+
`if`(s<t, t, -t))(a(n-1), combinat[numbpart](n)))
end:
seq(a(n), n=0..70);
MATHEMATICA
a[n_] := a[n] = If[n<0, 0, With[{a1 = a[n-1], p = PartitionsP[n]}, If[p>a1, a1 + p, a1 - p]]];
a /@ Range[0, 70] (* Jean-François Alcover, Jan 05 2021 *)
PROG
(PARI) lista(nn) = {my(va = vector(nn)); va[1] = 1; for (n=2, nn, my(p = numbpart(n-1)); va[n] = va[n-1] - p; if (va[n] < 0, va[n] += 2*p); ); va; } \\ Michel Marcus, Jan 06 2021
KEYWORD
nonn
AUTHOR
Alois P. Heinz, Jan 11 2020
STATUS
approved