OFFSET
0,7
LINKS
FORMULA
EXAMPLE
a(9) = #{6+3, 5+4, 5+2+1+1, 4+2+2+1, 2+2+2+1+1+1} = 5;
a(10) = #{8+2, 5+3+1+1, 4+3+2+1, 3+2+2+1+1+1} = 4.
MAPLE
b:= proc(n, i, t) local m; m:= n- `if`(t>0, t, -2*t); if m<0 then 0 elif n=0 then 1 elif i<3 then `if`(irem(m, 3)=0, 1, 0) else b(n, i, t):= b(n-i, i, t+ `if`(isprime(i), 1, -1)) +b(n, i-1, t) fi end: a:= n-> b(n, n, 0): seq(a(n), n=0..60); # Alois P. Heinz, Apr 30 2009
MATHEMATICA
pnpQ[n_]:=Count[n, _?PrimeQ]==Length[n]/2; Table[Count[ IntegerPartitions[ n], _?pnpQ], {n, 60}] (* Harvey P. Dale, Feb 02 2014 *)
b[n_, i_, t_] := b[n, i, t] = Module[{m}, m = n - If[t > 0, t, -2t]; Which[m < 0, 0, n == 0, 1, i < 3, If[Mod[m, 3] == 0, 1, 0], True, b[n, i, t] = b[n-i, i, t + If[PrimeQ[i], 1, -1]] + b[n, i-1, t]]];
a[n_] := b[n, n, 0];
a /@ Range[0, 60] (* Jean-François Alcover, May 30 2021, after Alois P. Heinz *)
PROG
(PARI)
parts(n)={1/(prod(k=1, n, 1 - if(isprime(k), y, 1/y)*x^k + O(x*x^n)))}
{my(n=60); apply(p->polcoeff(p, 0), Vec(parts(n)))} \\ Andrew Howroyd, Dec 29 2017
(Python)
from sympy import isprime
from sympy.utilities.iterables import partitions
def c(p): return 2*sum(p[i] for i in p if isprime(i)) == sum(p.values())
def a(n): return sum(1 for p in partitions(n) if c(p))
print([a(n) for n in range(55)]) # Michael S. Branicky, Jun 30 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
Reinhard Zumkeller, Jan 23 2009
STATUS
approved