login
Number of parts in all the compositions of n into primes (i.e., in all ordered sequences of primes having sum n).
5

%I #28 Jun 01 2021 08:06:24

%S 1,1,2,5,5,14,17,32,53,76,139,198,334,515,798,1280,1938,3075,4710,

%T 7299,11298,17296,26738,40874,62763,96036,146674,224210,341562,520767,

%U 792375,1204951,1831124,2779234,4217008,6391663,9683056,14659038,22177341

%N Number of parts in all the compositions of n into primes (i.e., in all ordered sequences of primes having sum n).

%C a(n) = Sum_{k=1..floor(n/2)} k*A121303(n,k).

%H Alois P. Heinz, <a href="/A121304/b121304.txt">Table of n, a(n) for n = 2..2000</a>

%F G.f.: (Sum_{i>=1} z^prime(i))/(1 - Sum_{i>=1} z^prime(i))^2.

%e 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.

%p 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);

%p # second Maple program:

%p b:= proc(n) option remember; `if`(n=0, [1, 0], add(

%p `if`(isprime(j), (p->p+[0, p[1]])(b(n-j)), 0), j=1..n))

%p end:

%p a:= n-> b(n)[2]:

%p seq(a(n), n=2..50); # _Alois P. Heinz_, Nov 08 2013, revised Feb 12 2021

%t 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 *)

%t 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 *)

%t b[n_] := b[n] = If[n == 0, {1, 0}, Sum[If[PrimeQ[j],

%t Function[p, p+{0, p[[1]]}][b[n-j]], {0, 0}], {j, 1, n}]];

%t a[n_] := b[n][[2]];

%t a /@ Range[2, 50] (* _Jean-François Alcover_, Jun 01 2021, after _Alois P. Heinz_ *)

%Y Cf. A023360, A121303.

%K nonn

%O 2,3

%A _Emeric Deutsch_, Aug 06 2006