This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A022895 #28 Jan 27 2024 20:24:47 %S A022895 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, %T A022895 95160,0,335579,0,1202236,0,4267477,0,15318171,0,55248419,0,200711050, %U A022895 0,733704990,0,2696599982,0,9941660942,0,36928370497,0,136801720627,0 %N A022895 Number of solutions to c(1)*prime(1) + ... + c(n)*prime(n) = 1, where c(i) = +-1 for i > 1, c(1) = 1. %H A022895 Alois P. Heinz, <a href="/A022895/b022895.txt">Table of n, a(n) for n = 1..500</a> %F A022895 a(n) = [x^1] Product_{k=2..n} (x^prime(k) + 1/x^prime(k)). - _Ilya Gutkovskiy_, Jan 26 2024 %e A022895 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}. %t A022895 {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}] %t A022895 (* A022895, a(n) = number of solutions of "sum = s" using Prime(f) to Prime(f+n-1) *) %t A022895 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 *) %o A022895 (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 %o A022895 (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 %Y A022895 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)). %Y A022895 Cf. A261061 - A261063 and A261045 (r.h.s. = -1); A261057, A261059, A261060 and A261044 (r.h.s. = -2); A113040 - A113042. %K A022895 nonn %O A022895 1,8 %A A022895 _Clark Kimberling_ %E A022895 Corrected and extended by _Clark Kimberling_, Oct 01 2013 %E A022895 a(23)-a(49) from _Alois P. Heinz_, Aug 06 2015 %E A022895 Cross-references from _M. F. Hasler_, Aug 08 2015