Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #18 Dec 06 2014 21:55:09
%S 0,0,1,1,1,5,11,28,69,164,437,1104,2887,7778,20861,55610,148857,
%T 408694,1112103,3059571,8519916,23586160,65766961,183122954,508287720,
%U 1423807763,4019399991,11359914488,32294035715,91866217942,258134484981,732226048291
%N Number of solutions to p(n) = Sum_{i=1..n-1} c(i)*p(i) with c(i) in {-1,0,1} and p(n) = n-th prime.
%H Alois P. Heinz and Ray Chandler, <a href="/A215221/b215221.txt">Table of n, a(n) for n = 1..1000</a> (first 200 terms from Alois P. Heinz)
%F a(n) = A215222(A000040(n)).
%e a(3) = 1: prime(3) = 5 = 3+2.
%e a(4) = 1: prime(4) = 7 = 5+2.
%e a(5) = 1: prime(5) = 11 = 7+5-3+2.
%e a(6) = 5: prime(6) = 13 = 7+5+3-2 = 11+2 = 11+5-3 = 11+7-3-2 = 11+7-5.
%e a(7) = 11: prime(7) = 17 = 7+5+3+2 = 11+5+3-2 = 11+7-3+2 = 13+5-3+2 = 13+7-3 = 13+7-5+2 = 13-11+7+5+3 = 13+11-5-2 = 13+11-7 = 13+11-7-5+3+2 = 13+11-7+5-3-2.
%p sp:= proc(n) option remember; `if`(n=0, 0, ithprime(n)+sp(n-1)) end:
%p b := proc(n, i) option remember; `if`(n>sp(i), 0, `if`(i=0, 1,
%p b(n, i-1)+ b(n+ithprime(i), i-1)+ b(abs(n-ithprime(i)), i-1)))
%p end:
%p a:= n-> b(ithprime(n), n-1):
%p seq(a(n), n=1..40);
%t nmax = 40; d = {1}; a1 = {};
%t Do[
%t p = Prime[n];
%t i = Ceiling[Length[d]/2] + p;
%t AppendTo[a1, If[i > Length[d], 0, d[[i]]]];
%t d = PadLeft[d, Length[d] + 2 p] + PadRight[d, Length[d] + 2 p] +
%t PadLeft[PadRight[d, Length[d] + p], Length[d] + 2 p];
%t , {n, nmax}];
%t a1 (* _Ray Chandler_, Mar 11 2014 *)
%Y Cf. A000040, A007504, A022894, A083309, A113040, A215222.
%K nonn
%O 1,6
%A _Alois P. Heinz_, Aug 06 2012