A276420 Number of palindromic compositions of n into prime parts.
1, 0, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 5, 6, 8, 7, 12, 14, 16, 17, 26, 27, 36, 40, 55, 56, 81, 88, 118, 124, 177, 189, 257, 275, 384, 404, 564, 605, 833, 880, 1233, 1314, 1813, 1929, 2685, 2850, 3956, 4215, 5845, 6203, 8629, 9185, 12731, 13531, 18807, 19994
Offset: 0
Keywords
Examples
a(9) = 2 because we have [2,5,2] and [3,3,3]. a(12) = 5 because we have [5,2,5], [2,3,2,3,2], [3,2,2,2,3], [3,3,3,3], and [2,2,2,2,2,2].
Links
- Alois P. Heinz, Table of n, a(n) for n = 0..10000
- V. E. Hoggatt, Jr., and Marjorie Bicknell, Palindromic compositions, Fibonacci Quart., Vol. 13(4), 1975, pp. 350-356.
Programs
-
Maple
F := sum(z^ithprime(j),j=1..90): F2:=sum(z^(2*ithprime(j)),j=1..90): g:= (1+F)/(1-F2): gser:=series(g,z=0,55): seq(coeff(gser,z,n),n=0..50); # second Maple program: a:= proc(n) option remember; `if`(n=0 or isprime(n), 1, 0)+ add(`if`(isprime(j), a(n-2*j), 0), j=1..n/2) end: seq(a(n), n=0..60); # Alois P. Heinz, Sep 02 2016
-
Mathematica
Table[Count[Flatten[Map[Permutations, Select[IntegerPartitions@ n, Times @@ Boole@ Map[PrimeQ, #] > 0 &]], 1], w_ /; Reverse@ w == w], {n, 0, 40}] (* Michael De Vlieger, Sep 02 2016 *) a[n_] := a[n] = If[n == 0 || PrimeQ[n], 1, 0] + Sum[If[PrimeQ[j], a[n - 2*j], 0], {j, 1, n/2}]; a /@ Range[0, 60] (* Jean-François Alcover, Jun 01 2021, after Alois P. Heinz *)
Formula
G.f.: g(z) = (1+F(z))/(1-F(z^2)), where F(z) = Sum_{p prime} z^p = z^2 + z^3 + z^5 + z^7 + ... .