A121304 Number of parts in all the compositions of n into primes (i.e., in all ordered sequences of primes having sum n).
1, 1, 2, 5, 5, 14, 17, 32, 53, 76, 139, 198, 334, 515, 798, 1280, 1938, 3075, 4710, 7299, 11298, 17296, 26738, 40874, 62763, 96036, 146674, 224210, 341562, 520767, 792375, 1204951, 1831124, 2779234, 4217008, 6391663, 9683056, 14659038, 22177341
Offset: 2
Keywords
Examples
a(8) = 17 because the compositions of 8 into primes are [3,5], [5,3], [2,3,3], [3,2,3], [3,3,2] and [2,2,2,2], having a total of 2+2+3+3+3+4 = 17 parts.
Links
- Alois P. Heinz, Table of n, a(n) for n = 2..2000
Programs
-
Maple
g:=sum(z^ithprime(i),i=1..53)/(1-sum(z^ithprime(i),i=1..53))^2: gser:=series(g,z=0,48): seq(coeff(gser,z,n),n=2..45); # second Maple program: b:= proc(n) option remember; `if`(n=0, [1, 0], add( `if`(isprime(j), (p->p+[0, p[1]])(b(n-j)), 0), j=1..n)) end: a:= n-> b(n)[2]: seq(a(n), n=2..50); # Alois P. Heinz, Nov 08 2013, revised Feb 12 2021
-
Mathematica
nn=40;a[x_]:=Sum[x^Prime[n],{n,1,nn}];Drop[CoefficientList[Series[D[1/(1-y a[x]),y]/.y ->1,{x,0,nn}],x],2] (* Geoffrey Critzer, Nov 08 2013 *) Table[Length[Flatten[Union[Flatten[Permutations/@Select[ IntegerPartitions[ n], AllTrue[ #,PrimeQ]&],1]]]],{n,2,40}] (* The program uses the AllTrue function from Mathematica version 10 *) (* Harvey P. Dale, Oct 24 2016 *) b[n_] := b[n] = If[n == 0, {1, 0}, Sum[If[PrimeQ[j], Function[p, p+{0, p[[1]]}][b[n-j]], {0, 0}], {j, 1, n}]]; a[n_] := b[n][[2]]; a /@ Range[2, 50] (* Jean-François Alcover, Jun 01 2021, after Alois P. Heinz *)
Formula
G.f.: (Sum_{i>=1} z^prime(i))/(1 - Sum_{i>=1} z^prime(i))^2.
Comments