A219181 Number of partitions of n into the maximal possible number of distinct prime parts or 0 if there are no such partitions.
1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 2, 2, 2, 1, 2, 1, 3, 1, 3, 2, 4, 2, 4, 2, 5, 2, 1, 4, 1, 4, 1, 4, 1, 6, 2, 6, 1, 6, 2, 8, 4, 10, 2, 1, 5, 1, 6, 1, 5, 2, 6, 2, 10, 1, 9, 1, 11, 4, 15, 3, 14, 3, 1, 6, 1, 6, 1, 5, 1, 10, 1, 11
Offset: 0
Examples
a(18) = 2 because there are 2 partitions of 18 into 3 distinct prime parts ([2,3,13], [2,5,11]) but no partitions of 18 into more than 3 distinct prime parts.
Links
- Alois P. Heinz, Table of n, a(n) for n = 0..3500
Programs
-
Maple
with(numtheory): b:= proc(n, i) option remember; `if`(n=0, [1], `if`(i<1, [], zip((x, y)->x+y, b(n, i-1), [0, `if`(ithprime(i)>n, [], b(n-ithprime(i), i-1))[]], 0))) end: a:= proc(n) local l; l:=b(n,pi(n)); while nops(l)>0 and l[-1]=0 do l:= subsop(-1=NULL, l) od; `if`(nops(l)=0, 0, l[-1]) end: seq(a(n), n=0..100);
-
Mathematica
zip = With[{m = Max[Length[#1], Length[#2]]}, PadRight[#1, m] + PadRight[#2, m]]&; b[n_, i_] := b[n, i] = If[n == 0, {1}, If[i<1, {}, zip[b[n, i-1], Join[{0}, If[Prime[i]>n, {}, b[n-Prime[i], i-1]]]]]]; a[n_] := (l = b[n, PrimePi[n]]; While[Length[l]>0 && l[[-1]] == 0, l = ReplacePart[l, -1 -> Nothing]]; If[Length[l] == 0, 0, l[[-1]]]); Table[a[n], {n, 0, 100}] (* Jean-François Alcover, Feb 12 2017, translated from Maple *)
Comments