A022903 Number of solutions to c(1)*prime(4) + ... + c(n)*prime(n+3) = 0, where c(i) = +-1 for i>1, c(1) = 1.
0, 0, 0, 1, 0, 0, 0, 0, 0, 6, 0, 9, 0, 61, 0, 131, 0, 486, 0, 2029, 0, 5890, 0, 21127, 0, 75979, 0, 273657, 0, 1032161, 0, 3694665, 0, 12989200, 0, 48409376, 0, 174262116, 0, 642786775, 0, 2402713235, 0, 8918299277, 0, 32868170524, 0, 123143998606, 0
Offset: 1
Keywords
Examples
a(10) counts these 6 solutions: {7, -11, -13, -17, -19, -23, 29, -31, 37, 41}, {7, 11, -13, 17, 19, -23, 29, 31, -37, -41}, {7, 11, -13, 17, 19, 23, -29, -31, 37, -41}, {7, 11, 13, -17, -19, 23, 29, 31, -37, -41}, {7, 11, 13, -17, 19, 23, -29, -31, -37, 41}, {7, 11, 13, 17, -19, -23, 29, -31, 37, -41}.
Links
- Alois P. Heinz, Table of n, a(n) for n = 1..500
Crossrefs
Programs
-
Maple
A022903 := proc(n) local a,b,cs,cslen ; a := 0 ; for b from 0 to 2^(n-1)-1 do cs := convert(b,base,2) ; cslen := nops(cs) ; if cslen < n-1 then cs := [op(cs),seq(0,i=1..n-1-cslen)] ; end if; if ithprime(4)+add( (-1+2*op(i-4,cs)) *ithprime(i),i=5..n+3) = 0 then a := a+1 ; end if; end do: a ; end proc: for n from 1 do print(n,A022903(n)) ; end do: # R. J. Mathar, Aug 06 2015
-
Mathematica
{f, s} = {4, 0}; Table[t = Map[Prime[# + f - 1] &, Range[2, z]]; Count[Map[Apply[Plus, #] &, Map[t # &, Tuples[{-1, 1}, Length[t]]]], s - Prime[f]], {z, 22}] (* A022903, a(n) = number of solutions of "sum = s" using Prime(f) to Prime(f+n-1) *) n = 10; t = Map[Prime[# + f - 1] &, Range[n]]; Map[#[[2]] &, Select[Map[{Apply[Plus, #], #} &, Map[t # &, Map[Prepend[#, 1] &, Tuples[{-1, 1}, Length[t] - 1]]]], #[[1]] == s &]] (* the 6 solutions of using n=10 primes; Peter J. C. Moses, Oct 01 2013 *)
-
PARI
A022903(n, rhs=0, firstprime=4)={rhs-=prime(firstprime); my(p=vector(n-1, i, prime(i+firstprime))); sum(i=1, 2^#p-1, sum(j=1, #p, (-1)^bittest(i, j-1)*p[j])==rhs)} \\ For illustrative purpose, too slow for n >> 20. - M. F. Hasler, Aug 08 2015
Formula
a(2n-1) = 0 for all n >= 1 because an odd number of odd terms on the l.h.s. cannot sum to zero. - M. F. Hasler, Aug 08 2015
a(n) = [x^7] Product_{k=5..n+3} (x^prime(k) + 1/x^prime(k)). - Ilya Gutkovskiy, Jan 28 2024
Extensions
a(23)-a(49) from Alois P. Heinz, Aug 06 2015