OFFSET
1,7
COMMENTS
a(n) = number of partitions of A000040(n) into n primes.
If n > 1 and prime(n) - prime(n-1) = 2 (twin primes), then the number of partitions of prime(n) into n primes that don't contain 2 is equal to a(n) - a(n-1); every partition of primes in a(n) that does contain a 2 matches a partition of primes in a(n-1) with an added partition for 2. Further, if n is even, then a(n) = a(n-1).
LINKS
Alois P. Heinz, Table of n, a(n) for n = 1..600 (first 100 terms from Doug Bell)
FORMULA
EXAMPLE
a(9) = 3 because 23 is the ninth prime number (A000040(9) = 23), and 23 can be partitioned into nine primes in three ways: [2,2,2,2,2,2,2,2,7], [2,2,2,2,2,2,3,3,5] and [2,2,2,2,3,3,3,3,3].
MAPLE
N:= 100: # to get a(1) to a(N)
Primes:= [seq(ithprime(i), i=1..N)]:
W:= proc(n, m, j) option remember;
if n < 0 then return 0 fi;
if n=0 then if m=0 then return 1 else return 0 fi fi;
add(W(n-Primes[i], m-1, i), i=1..j)
end proc:
seq(W(Primes[n], n, n), n = 1 .. N); # Robert Israel, Jun 22 2015
MATHEMATICA
f[n_] := Length@ IntegerPartitions[ Prime@n, {n}, Prime@ Range@ n]; Array[f, 50] (* Giovanni Resta, Jun 23 2015 *)
PROG
(PARI) a(n) = {nb = 0; forpart(p=prime(n), ok=1; for (k=1, n, if (!isprime(p[k]), ok=0; break)); nb += ok, [2, prime(n)], [n, n]); nb; } \\ Michel Marcus, Jun 23 2015
(Perl) use ntheory ":all"; use List::MoreUtils qw/all/; sub a259254 { my($n, $sum)=(shift, 0); forpart { $sum++ if all { is_prime($_) } @_; } nth_prime($n), {n=>$n, amin=>2}; $sum; } say a259254($_) for 1..60; # Dana Jacobsen, Dec 15 2015
(Perl) use ntheory ":all";
use Memoize; memoize 'W';
sub W {
my($n, $m, $j) = @_;
return 0 if $n < 0;
return ($m == 0) ? 1 : 0 if $n == 0;
vecsum( map { W($n-nth_prime($_), $m-1, $_) } 1 .. $j );
}
sub A259254 { my $n = shift; W(nth_prime($n), $n, $n); }
print "$_ ", A259254($_), "\n" for 1..60; # Dana Jacobsen, Dec 15 2015
CROSSREFS
KEYWORD
nonn
AUTHOR
Doug Bell, Jun 22 2015
STATUS
approved