cp's OEIS Frontend

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.

Showing 1-10 of 16 results. Next

A022894 Number of solutions to c(1)*prime(1) +...+ c(2n+1)*prime(2n+1) = 0, where c(i) = +-1 for i > 1, c(1) = 1.

Original entry on oeis.org

0, 1, 1, 2, 5, 13, 39, 122, 392, 1286, 4341, 14860, 51085, 178402, 634511, 2260918, 8067237, 29031202, 105250449, 383579285, 1404666447, 5171065198, 19141008044, 71124987313, 263548339462, 983424096451, 3684422350470, 13818161525284, 51938115653565
Offset: 0

Views

Author

Keywords

Comments

c(1)*prime(1) + ... + c(2n)*prime(2n) = 0 has no solution, because the l.h.s. has an odd number of odd terms and the r.h.s. is even.

Examples

			a(1) = 1 because 2 + 3 - 5 = 0,
a(2) = 1 because 2 - 3 + 5 + 7 - 11 = 0,
a(3) = 2 because
  2 + 3 - 5 - 7 + 11 + 13 - 17 =
  2 + 3 - 5 + 7 - 11 - 13 + 17 = 0.
a(4) = 5 because
  2 - 3 - 5 + 7 + 11 + 13 + 17 - 19 - 23 =
  2 - 3 + 5 - 7 + 11 + 13 - 17 + 19 - 23 =
  2 - 3 + 5 + 7 - 11 - 13 + 17 + 19 - 23 =
  2 - 3 + 5 + 7 - 11 + 13 - 17 - 19 + 23 =
  2 + 3 + 5 - 7 - 11 - 13 + 17 - 19 + 23 = 0
and there are no others up through the ninth prime.
		

Crossrefs

Cf. A113040, A215036, A083309 (sums of odd primes).
Cf. A022895, A022896 (r.h.s. = 1 & 2, using all primes), A083309 and A022897 - A022899 (using primes >= 3), A022900 - A022902 (using primes >=5), A022903, A022904, A022920 (using primes >= 7); A261061 - A261063 & A261045 (r.h.s. = -1); A261057, A261059, A261060 & A261044 (r.h.s. = -2).
Bisection (odd part) of A306443.

Programs

  • Maple
    sp:= proc(n) sp(n):= `if`(n=1, 0, ithprime(n)+sp(n-1)) end:
    b := proc(n,i) option remember; `if`(n>sp(i), 0, `if`(i=1, 1,
            b(n+ithprime(i), i-1)+ b(abs(n-ithprime(i)), i-1)))
         end:
    a:= n-> b(2, 2*n+1):
    seq(a(n), n=0..40);  # Alois P. Heinz, Aug 05 2012
  • Mathematica
    Do[a = Table[ Prime[i], {i, 1, n} ]; c = 0; k = 2^(n - 1); While[k < 2^n, If[ Apply[ Plus, a*(-1)^(IntegerDigits[k, 2] + 1)] == 0, c++ ]; k++ ]; Print[c], {n, 1, 32, 2} ]
  • PARI
    A022894={a(n, s=0-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, a(abs(s), max(sum(i=p+1, p+(p>1)+2*n, prime(i)),1), prime(p+(p>1)+2*n))))} \\ M. F. Hasler, Aug 09 2015

Formula

Conjecture: limit_{n->oo} a(n)^(1/n) = 4. - Vaclav Kotesovec, Jun 05 2019
a(n) is the constant term in expansion of (1/2) * Product_{k=1..2*n+1} (x^prime(k) + 1/x^prime(k)). - Ilya Gutkovskiy, Jan 25 2024

Extensions

Edited by Robert G. Wilson v, Jan 29 2002
More terms from T. D. Noe, Jan 16 2007
Edited by M. F. Hasler, Aug 09 2015

A261057 Number of solutions to c(1)*prime(1)+...+c(2n-1)*prime(2n-1) = -2, where c(i) = +-1 for i > 1, c(1) = 1.

Original entry on oeis.org

0, 0, 1, 1, 5, 13, 40, 123, 388, 1284, 4332, 14868, 51094, 178361, 634422, 2260717, 8066841, 29030051, 105247340, 383574146, 1404657053, 5171018981, 19140750300, 71124341227, 263546155710, 983417309702, 3684399940711, 13818092760075, 51937827473594, 195956606402526
Offset: 1

Views

Author

M. F. Hasler, Aug 08 2015

Keywords

Comments

There cannot be a solution for an even number of terms on the l.h.s. because there would be an odd number of odd terms but the r.h.s. is even.

Examples

			a(1) = a(2) = 0 because prime(1) and prime(1) +- prime(2) +- prime(3) is always different from -2.
a(3) = 1 because prime(1) - prime(2) - prime(3) - prime(4) + prime(5) = -2.
		

Crossrefs

Cf. A261059, A261060, A261045 (starting with prime(2) - prime(4)), A261061 - A261063 and A261044 (r.h.s. = -1), A022894 - A022904, A083309, A022920 (r.h.s. = 0, 1 or 2); A113040, A113041, A113042.

Programs

  • Maple
    s:= proc(n) option remember;
          `if`(n<2, 0, ithprime(n)+s(n-1))
        end:
    b:= proc(n, i) option remember; `if`(n>s(i), 0, `if`(i=1, 1,
          b(abs(n-ithprime(i)),i-1)+b(n+ithprime(i),i-1)))
        end:
    a:= n-> b(4, 2*n-1):
    seq(a(n), n=1..30);  # Alois P. Heinz, Aug 08 2015
  • Mathematica
    s[n_] := s[n] = If[n<2, 0, Prime[n]+s[n-1]]; b[n_, i_] := b[n, i] = If[n > s[i], 0, If[i == 1, 1, b[Abs[n-Prime[i]], i-1] + b[n+Prime[i], i-1]]]; a[n_] := b[4, 2*n-1];  Table[a[n], {n, 1, 30}] (* Jean-François Alcover, Nov 11 2015, after Alois P. Heinz *)
  • PARI
    A261057(n,rhs=-2,firstprime=1)={rhs-=prime(firstprime);my(p=vector(2*n-2+bittest(rhs,0),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 >> 10.
    
  • PARI
    a(n, s=-2-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, a(abs(s), max(sum(i=p+1, p+=2*n-2+bittest(s,0), prime(i)),1), prime(p))))} \\ M. F. Hasler, Aug 09 2015

Formula

a(n) = A113041(n) - A022896(2n-1).
a(n) = [x^4] Product_{k=2..2*n-1} (x^prime(k) + 1/x^prime(k)). - Ilya Gutkovskiy, Jan 31 2024

Extensions

a(26)-a(30) from Alois P. Heinz, Jan 04 2019

A022895 Number of solutions to c(1)*prime(1) + ... + c(n)*prime(n) = 1, where c(i) = +-1 for i > 1, c(1) = 1.

Original entry on oeis.org

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
Offset: 1

Views

Author

Keywords

Examples

			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}.
		

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.

Programs

  • 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 *)
  • 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

Formula

a(n) = [x^1] Product_{k=2..n} (x^prime(k) + 1/x^prime(k)). - Ilya Gutkovskiy, Jan 26 2024

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

A022896 Number of solutions to c(1)*prime(1) + ... + c(n)*prime(n) = 2, where c(i) = +-1 for i > 1, c(1) = 1.

Original entry on oeis.org

1, 0, 0, 0, 0, 0, 2, 0, 4, 0, 14, 0, 38, 0, 126, 0, 394, 0, 1290, 0, 4344, 0, 14846, 0, 51068, 0, 178436, 0, 634568, 0, 2261052, 0, 8067296, 0, 29031484, 0, 105251904, 0, 383580180, 0, 1404666680, 0, 5171079172, 0, 19141098744, 0, 71125205900, 0, 263549059326
Offset: 1

Views

Author

Keywords

Examples

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

Crossrefs

Cf. A022894 (r.h.s. = 0), A022895 (r.h.s. = 1), A022897, ..., A022904, A022920 (using primes >= 7), A083309; A261061 - A261063 and A261045 (r.h.s. = -1); A261057, A261059, A261060 and A261044 (r.h.s. = -2); A113040, A113041, A113042. - M. F. Hasler, Aug 08 2015

Programs

  • Mathematica
    {f, s} = {1, 2}; 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}]
    (* A022896, a(n) = number of solutions of "sum = s" using Prime(f) to Prime(f+n-1) *)
    n = 7; 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 2 solutions of using n=7 primes; Peter J. C. Moses, Oct 01 2013 *)
  • PARI
    A022896(n, rhs=2, firstprime=1)={rhs-=prime(firstprime); my(p=vector(n-1, i, prime(i+firstprime))); !(rhs||#p)+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=2-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)))} \\ M. F. Hasler, Aug 09 2015

Formula

a(2n-1) = A113041(n) - A261057(n), a(2n) = 0 because there is an odd number of odd terms on the left hand side, but the right hand side is even. - M. F. Hasler, Aug 09 2015
a(n) = [x^0] Product_{k=2..n} (x^prime(k) + 1/x^prime(k)). - Ilya Gutkovskiy, Jan 26 2024

Extensions

Corrected and extended by Clark Kimberling, Oct 01 2013
a(23)-a(49) from Alois P. Heinz, Aug 06 2015

A306443 Number of ways of partitioning the set of the first n primes into two subsets whose sums differ at most by 1.

Original entry on oeis.org

1, 0, 1, 1, 1, 1, 3, 2, 6, 5, 16, 13, 45, 39, 138, 122, 439, 392, 1417, 1286, 4698, 4341, 16021, 14860, 55146, 51085, 190274, 178402, 671224, 634511, 2404289, 2260918, 8535117, 8067237, 30635869, 29031202, 110496946, 105250449, 401422210, 383579285, 1467402238
Offset: 0

Views

Author

Alois P. Heinz, May 31 2019

Keywords

Examples

			a(8) = 6: 2,17,19/3,5,7,11,13; 3,5,11,19/2,7,13,17; 3,5,13,17/2,7,11,19; 3,7,11,17/2,5,13,19; 2,3,5,11,17/7,13,19; 2,5,7,11,13/3,17,19.
a(9) = 5: 2,3,5,17,23/7,11,13,19; 2,5,7,13,23/3,11,17,19; 2,5,7,17,19/3,11,13,23; 2,5,11,13,19/3,7,17,23; 2,7,11,13,17/3,5,19,23.
		

Crossrefs

Bisections give: A022894 (odd part), A113040 (even part).

Programs

  • Maple
    s:= proc(n) s(n):= `if`(n=0, 1, ithprime(n)+s(n-1)) end:
    b:= proc(n, i) option remember; `if`(i=0, `if`(n<=1, 1, 0),
         `if`(n>s(i), 0, (p->b(n+p, i-1)+b(abs(n-p), i-1))(ithprime(i))))
        end:
    a:= n-> ceil(b(0, n)/2):
    seq(a(n), n=0..45);
  • Mathematica
    s[n_] := s[n] = If[n == 0, 1, Prime[n] + s[n - 1]];
    b[n_, i_] := b[n, i] = If[i==0, If[n <= 1, 1, 0], If[n > s[i], 0, Function[ p, b[n + p, i - 1] + b[Abs[n - p], i - 1]][Prime[i]]]];
    a[n_] := Ceiling[b[0, n]/2];
    a /@ Range[0, 45] (* Jean-François Alcover, Apr 30 2020, after Alois P. Heinz *)

A113042 Number of solutions to +-p(1)+-p(2)+-...+-p(2n) = 3 where p(i) is the i-th prime.

Original entry on oeis.org

0, 2, 1, 7, 15, 45, 139, 438, 1419, 4703, 16019, 55146, 190254, 671215, 2404179, 8534995, 30635448, 110495549, 401418693, 1467388464, 5393131894, 19883104535, 73856058401, 273600682457, 1017557492609, 3803885439979, 14266466901249, 53564801078049
Offset: 1

Views

Author

Floor van Lamoen, Oct 12 2005

Keywords

Comments

+-p(1)+-p(2)+-...+-p(2n+1) = 3 does not have solutions, since the left hand side is even. [Corrected and edited by M. F. Hasler, Aug 09 2015]

Crossrefs

Cf. A022894 - A022904, A022920, A083309; A261061 - A261063 and A261045 (r.h.s. = -1); A261057, A261059, A261060 and A261044 (r.h.s. = -2); A113040, A113041.

Programs

  • Maple
    A113042:=proc(n) local i,j,p,t; t:= NULL; for j from 2 to 2*n by 2 do p:=1; for i to j do p:=p*(x^(-ithprime(i))+x^(ithprime(i))); od; t:=t,coeff(p,x,3); od; t; end;
    # second Maple program
    sp:= proc(n) sp(n):= `if`(n=0, 0, ithprime(n)+sp(n-1)) end:
    b := proc(n, i) option remember; `if`(n>sp(i), 0, `if`(i=0, 1,
            b(n+ithprime(i), i-1)+ b(abs(n-ithprime(i)), i-1)))
         end:
    a:= n-> b(3, 2*n):
    seq(a(n), n=1..30);  # Alois P. Heinz, Aug 05 2012
  • Mathematica
    sp[n_] := sp[n] = If[n == 0, 0, Prime[n] + sp[n-1]]; b[n_, i_] := b[n, i] = If[n>sp[i], 0, If[i == 0, 1, b[n + Prime[i], i-1] + b[Abs[n - Prime[i]], i-1]]]; a[n_] := b[3, 2*n]; Table[a[n], {n, 1, 30}] (* Jean-François Alcover, Jan 31 2017, after Alois P. Heinz *)

Formula

a(n) = [x^3] Product_{k=1..2*n} (x^prime(k) + 1/x^prime(k)). - Ilya Gutkovskiy, Jan 30 2024

A113041 Number of solutions to +-p(1)+-p(2)+-...+-p(2n-1) = 2, where p(i) is the i-th prime.

Original entry on oeis.org

1, 0, 1, 3, 9, 27, 78, 249, 782, 2574, 8676, 29714, 102162, 356797, 1268990, 4521769, 16134137, 58061535, 210499244, 767154326, 2809323733, 10342098153, 38281849044, 142249547127, 527095215036, 1966843667482, 7368829743507, 27636276043171, 103876045792060
Offset: 1

Views

Author

Floor van Lamoen, Oct 12 2005

Keywords

Comments

+-p(1)+-p(2)+-...+-p(2n) = 2 has no solutions, since the left hand side is odd.

Crossrefs

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

Programs

  • Maple
    A113041:=proc(n) local i,j,p,t; t:= NULL; for j to 2*n-1 by 2 do p:=1; for i to j do p:=p*(x^(-ithprime(i))+x^(ithprime(i))); od; t:=t,coeff(p,x,2); od; t; end;
    # second Maple program
    sp:= proc(n) sp(n):= `if`(n=0, 0, ithprime(n)+sp(n-1)) end:
    b := proc(n, i) option remember; `if`(n>sp(i), 0, `if`(i=0, 1,
            b(n+ithprime(i), i-1)+ b(abs(n-ithprime(i)), i-1)))
         end:
    a:= n-> b(2, 2*n-1):
    seq(a(n), n=1..30);  # Alois P. Heinz, Aug 05 2012
  • Mathematica
    sp[n_] := sp[n] = If[n == 0, 0, Prime[n] + sp[n-1]];
    b[n_, i_] := b[n, i] = If[n > sp[i], 0, If[i == 0, 1, b[n + Prime[i], i-1] + b[Abs[n - Prime[i]], i-1]]];
    a[n_] := b[2, 2n-1];
    Array[a, 30] (* Jean-François Alcover, Nov 02 2020, after Alois P. Heinz *)

Formula

a(n) = A022896(2n-1) + A261057(n). - M. F. Hasler, Aug 09 2015
a(n) = [x^2] Product_{k=1..2*n-1} (x^prime(k) + 1/x^prime(k)). - Ilya Gutkovskiy, Jan 30 2024

A350404 Number of solutions to +-2 +- 3 +- 5 +- 7 +- ... +- prime(n) = 0 or 1.

Original entry on oeis.org

1, 0, 1, 2, 1, 2, 3, 4, 6, 10, 16, 26, 45, 78, 138, 244, 439, 784, 1417, 2572, 4698, 8682, 16021, 29720, 55146, 102170, 190274, 356804, 671224, 1269022, 2404289, 4521836, 8535117, 16134474, 30635869, 58062404, 110496946, 210500898, 401422210, 767158570, 1467402238
Offset: 0

Views

Author

Ilya Gutkovskiy, Dec 29 2021

Keywords

Examples

			a(6) = 3: 2 + 3 + 5 - 7 + 11 - 13 =
         -2 + 3 + 5 - 7 - 11 + 13 =
         -2 + 3 - 5 + 7 + 11 - 13 = 1.
		

Crossrefs

Programs

  • Maple
    s:= proc(n) s(n):= `if`(n<1, 0, ithprime(n)+s(n-1)) end:
    b:= proc(n, i) option remember; `if`(n>s(i), 0, `if`(i=0, 1,
          b(n+ithprime(i), i-1)+b(abs(n-ithprime(i)), i-1)))
        end:
    a:=n-> b(0, n)+b(1, n):
    seq(a(n), n=0..45);  # Alois P. Heinz, Jan 16 2022
  • Mathematica
    s[n_] := s[n] = If[n < 1, 0, Prime[n] + s[n - 1]];
    b[n_, i_] := b[n, i] = If[n > s[i], 0, If[i == 0, 1,
         b[n + Prime[i], i - 1] + b[Abs[n - Prime[i]], i - 1]]];
    a[n_] := b[0, n] + b[1, n];
    Table[a[n], {n, 0, 45}] (* Jean-François Alcover, Mar 01 2022, after Alois P. Heinz *)
  • Python
    from itertools import product
    from sympy import prime, primerange
    def a(n):
        if n == 0: return 1
        nn = ["0"] + [str(i) for i in primerange(2, prime(n)+1)]
        return sum(eval("".join([*sum(zip(nn, ops+("", )), ())])) in {0, 1} for ops in product("+-", repeat=n))
    print([a(n) for n in range(18)]) # Michael S. Branicky, Jan 16 2022
    
  • Python
    from sympy import sieve, primerange
    from functools import cache
    @cache
    def b(n, i):
        maxsum = 0 if i == 0 else sum(p for p in primerange(2, sieve[i]+1))
        if n > maxsum: return 0
        if i == 0: return 1
        return b(n+sieve[i], i-1) + b(abs(n-sieve[i]), i-1)
    def a(n): return b(0, n) + b(1, n)
    print([a(n) for n in range(43)]) # Michael S. Branicky, Jan 16 2022

Extensions

a(39)-a(40) from Michael S. Branicky, Jan 16 2022

A215036 2 followed by "1,0" repeated.

Original entry on oeis.org

2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1
Offset: 1

Views

Author

N. J. A. Sloane, Aug 06 2012

Keywords

Comments

Take the first n primes and combine them with coefficients +1 and -1; then a(n) is the smallest number (in absolute value) that can be obtained.
For example, a(1) = 2, a(2) = 1 from 3-2 = 1; a(3) = 0 from -2-3+5 = 0; a(11) = 0 from 2-3-5-7+11-13+17+19-23-29+31 = 0.
Comment from Franklin T. Adams-Watters, Aug 05 2012: Sketch of proof that the above sum of primes results in this sequence. If S_n is the set of possible values of the signed sums for the first n primes, then S_{n+1} = S_n U (S_n + prime(n+1)) U (S_n - prime(n+1)). Beyond about n=4, this will be everything even or everything odd in an interval around zero, and then a fringe on either side; the size of the interval will be 2 * A007504(n) - k for some small k. Recursively, since prime(n) << A007504(n), this will continue to hold. Hence the sequence continues to alternate 0's and 1's. A quite modest estimate on the distribution of primes suffices to complete the proof.
For number of solutions see A022894, A113040; also A083309.

Crossrefs

Essentially the same as A135528, A059841, A000035.

Programs

A215221 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.

Original entry on oeis.org

0, 0, 1, 1, 1, 5, 11, 28, 69, 164, 437, 1104, 2887, 7778, 20861, 55610, 148857, 408694, 1112103, 3059571, 8519916, 23586160, 65766961, 183122954, 508287720, 1423807763, 4019399991, 11359914488, 32294035715, 91866217942, 258134484981, 732226048291
Offset: 1

Views

Author

Alois P. Heinz, Aug 06 2012

Keywords

Examples

			a(3) = 1: prime(3) = 5 = 3+2.
a(4) = 1: prime(4) = 7 = 5+2.
a(5) = 1: prime(5) = 11 = 7+5-3+2.
a(6) = 5: prime(6) = 13 = 7+5+3-2 = 11+2 = 11+5-3 = 11+7-3-2 = 11+7-5.
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.
		

Crossrefs

Programs

  • Maple
    sp:= proc(n) option remember; `if`(n=0, 0, ithprime(n)+sp(n-1)) end:
    b := proc(n, i) option remember; `if`(n>sp(i), 0, `if`(i=0, 1,
            b(n, i-1)+ b(n+ithprime(i), i-1)+ b(abs(n-ithprime(i)), i-1)))
         end:
    a:= n-> b(ithprime(n), n-1):
    seq(a(n), n=1..40);
  • Mathematica
    nmax = 40; d = {1}; a1 = {};
    Do[
      p = Prime[n];
      i = Ceiling[Length[d]/2] + p;
      AppendTo[a1, If[i > Length[d], 0, d[[i]]]];
      d = PadLeft[d, Length[d] + 2 p] + PadRight[d, Length[d] + 2 p] +
        PadLeft[PadRight[d, Length[d] + p], Length[d] + 2 p];
      , {n, nmax}];
    a1 (* Ray Chandler, Mar 11 2014 *)

Formula

a(n) = A215222(A000040(n)).
Showing 1-10 of 16 results. Next