cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A155515 Number of partitions of n into as many primes as nonprimes.

Original entry on oeis.org

1, 0, 0, 1, 1, 0, 3, 2, 3, 5, 4, 8, 12, 10, 15, 23, 22, 33, 42, 47, 64, 79, 90, 122, 147, 169, 219, 264, 312, 387, 465, 546, 679, 799, 950, 1151, 1365, 1599, 1937, 2270, 2678, 3181, 3735, 4374, 5192, 6046, 7082, 8318, 9684, 11281, 13208, 15313, 17798, 20702, 23951
Offset: 0

Views

Author

Reinhard Zumkeller, Jan 23 2009

Keywords

Examples

			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.
		

Crossrefs

Programs

  • 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 *)
  • 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

Formula

a(n) = A000041(n) - A355306(n). - Omar E. Pol, Jun 30 2022