login
This site is supported by donations to The OEIS Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A022895 Number of solutions to c(1)*prime(1) + ... + c(n)*prime(n) = 1, where c(i) = +-1 for i > 1, c(1) = 1. 8
0, 0, 0, 1, 0, 1, 0, 3, 0, 8, 0, 22, 0, 70, 0, 218, 0, 708, 0, 2354, 0, 8015, 0, 27561, 0, 95160, 0, 335579, 0, 1202236, 0, 4267477, 0, 15318171, 0, 55248419, 0, 200711050, 0, 733704990, 0, 2696599982, 0, 9941660942, 0, 36928370497, 0, 136801720627, 0 (list; graph; refs; listen; history; text; internal format)
OFFSET

1,8

LINKS

Alois P. Heinz, Table of n, a(n) for n = 1..500

EXAMPLE

a(8) counts these 3 solutions: {2, -3, -5, 7, -11, 13, 17, -19}, {2, -3, -5, 7, 11, -13, -17, 19}, {2, -3, 5, -7, -11, 13, -17, 19}.

MATHEMATICA

{f, s} = {1, 1}; 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}]

(* A022895, a(n) = number of solutions of "sum = s" using Prime(f) to Prime(f+n-1) *)

n = 8; 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 3 solutions using n=8 primes; Peter J. C. Moses, Oct 01 2013 *)

PROG

(PARI) A022895(n, rhs=1, firstprime=1)={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

(PARI) a(n, s=1-prime(1), p=1)={if(n<=s, if(s==p, n==s, a(abs(n-p), s-p, precprime(p-1))+a(n+p, s-p, precprime(p-1))), if(s<=0, if(n>1, a(abs(s), sum(i=p+1, p+n-1, prime(i)), prime(p+n-1)), !s)))} \\ On function call, s = r.h.s.- smallest prime; during recursion: sum of all primes to be used. - M. F. Hasler, Aug 09 2015

CROSSREFS

Cf. A022894 (r.h.s. = 0), A022896, ..., A022904, A083309, A022920 (variants with r.h.s. in {0, 1 or 2}, starting with prime(2) or prime(3) or prime(4)).

Cf. A261061 - A261063 and A261045 (r.h.s. = -1); A261057, A261059, A261060 and A261044 (r.h.s. = -2); A113040 - A113042.

Sequence in context: A201575 A194796 A147600 * A197416 A197512 A232272

Adjacent sequences:  A022892 A022893 A022894 * A022896 A022897 A022898

KEYWORD

nonn

AUTHOR

Clark Kimberling

EXTENSIONS

Corrected and extended by Clark Kimberling, Oct 01 2013

a(23)-a(49) from Alois P. Heinz, Aug 06 2015

Cross-references from M. F. Hasler, Aug 08 2015

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified September 15 18:47 EDT 2019. Contains 327083 sequences. (Running on oeis4.)