OFFSET
1,2
LINKS
Alois P. Heinz, Table of n, a(n) for n = 1..10000 (first 175 terms from Robert G. Wilson v)
FORMULA
a(n) = Sum_{k=1..n} k * A000586(n-k). - Max Alekseyev, Jul 14 2010
EXAMPLE
n=7 gives 11111 11, 2111 11, 311 11, 5 11, 5 2, 32 11. (Grouped in 5's) no. of 1's: 7, 5, 4, 2, 0, 2. Sum is 20, therefore a(7) = 20.
n=12 gives 11111 11111 11, 11111 11111 2, 11111 311 11, 11111 32 11, 11111 5 11, 5 2111 11, 5 311 11, 5 32 11, 7111 11, 721 11, 73 11, 73 2, 75, eleven 1, no. of 1's: 12, 10, 9, 7, 7, 5, 4, 2, 5, 3, 2, 0, 0, 1. Sum is 67, therefore a(12) = 67.
1: 1 => 1 2: 11, 2 => 2 3: 111, 21 => 4 4: 1111, 211, 22, 31 => 7 5: 11111, 2111, 311, 23 => 10 6: 11111 1, 2111 1, 311 1, 23 1, 5 1 => 15 and so on.
MAPLE
b:= proc(n, i) option remember; if n<=0 then 0 elif i=0 then n else b(n, i-1) +b(n-ithprime(i), i-1) fi end: # R. J. Mathar, Jul 14 2010
a:= n-> b(n, numtheory[pi](n)): seq(a(n), n=1..80); # Alois P. Heinz
MATHEMATICA
fQ[lst_List] := Sort@ Flatten@ Most@ Split@ lst == Rest@ Union@ lst; f[n_] := Sum[ Count[ Select[ IntegerPartitions[n, {k}, Join[{1}, Prime@ Range@ PrimePi@n]], fQ@# &], 1, 2], {k, n}]; Array[f, 50] (* improved by Robert G. Wilson v, Jul 20 2010 *)
(* second program: *)
b[n_, i_] := b[n, i] = If[n == 0, 1, If[i < 1, 0, b[n, i - 1] + If[Prime[i] > n, 0, b[n - Prime[i], i - 1]]]];
a[n_] := Sum[k*b[n - k, PrimePi[n - k]], {k, 1, n}];
Table[a[n], {n, 1, 80}] (* Jean-François Alcover, Aug 29 2016, after Alois P. Heinz *)
PROG
(PARI) a(n) = my(r); r = x/(1-x)^2 + O(x^(n+1)); forprime(p=2, n, r*=1+x^p); polcoeff(r, n) \\ Max Alekseyev, Jul 14 2010
CROSSREFS
KEYWORD
nonn
AUTHOR
Joseph Foley, Jul 12 2010
EXTENSIONS
Corrected and extended by R. J. Mathar, Jul 14 2010
STATUS
approved