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.

Previous Showing 21-30 of 36 results. Next

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

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

Original entry on oeis.org

0, 0, 0, 1, 0, 1, 0, 1, 0, 8, 0, 22, 0, 42, 0, 147, 0, 663, 0, 1803, 0, 7410, 0, 22463, 0, 87397, 0, 291211, 0, 1091736, 0, 3896012, 0, 13992225, 0, 49681944, 0, 184771042, 0, 677854904, 0, 2495656379, 0, 9260633829, 0, 34281074654, 0, 127420198855, 0
Offset: 1

Views

Author

Keywords

Examples

			a(8) counts the unique solution {5, -7, 11, -13, 17, -19, -23, 29}.
		

Crossrefs

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

Programs

  • Mathematica
    {f, s} = {3, 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}]
    (* A022900, 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 unique solution of using n=8 primes; Peter J. C. Moses, Oct 01 2013 *)
  • PARI
    A022900(n,rhs=0,firstprime=3)={rhs-=prime(firstprime);my(p=vector(n-1,i,prime(i+firstprime)));sum(i=1,2^(n-1),sum(j=1,#p,(1-bittest(i,j-1)<<1)*p[j])==rhs)} \\ For illustrative purpose, too slow for n >> 20. - M. F. Hasler, Aug 08 2015

Formula

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

Extensions

Corrected and extended by Clark Kimberling, Oct 01 2013
a(23)-a(49) from Alois P. Heinz, Aug 06 2015
Missing cross-references added by M. F. Hasler, Aug 08 2015

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

Original entry on oeis.org

0, 0, 1, 0, 6, 8, 30, 121, 385, 1102, 4207, 13263, 48904, 164298, 610450, 2108897, 7592564, 27444148, 100851443, 365507140, 1344593522, 4960584613, 18435632285, 68320148701, 254166868115, 951593812462, 3568369245595, 13386056545363, 50416752718382
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 all terms are odd but the r.h.s. is odd, too.

Examples

			a(1) = a(2) = 0 because prime(2) and prime(2) +- prime(3) +- prime(4) are always different from -1.
a(3) = 1 because the solution prime(2) + prime(3) - prime(4) + prime(5) - prime(6) = -1 is the only one involving prime(2) through prime(6).
		

Crossrefs

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

Programs

  • Maple
    s:= proc(n) option remember;
          `if`(n<3, 0, ithprime(n)+s(n-1))
        end:
    b:= proc(n, i) option remember; `if`(n>s(i), 0, `if`(i=2, 1,
          b(abs(n-ithprime(i)), i-1)+b(n+ithprime(i), i-1)))
        end:
    a:= n-> b(4, 2*n):
    seq(a(n), n=1..30);  # Alois P. Heinz, Aug 08 2015
  • Mathematica
    s[n_] := s[n] = If[n < 3, 0, Prime[n] + s[n-1]];
    b[n_, i_] := b[n, i] = If[n > s[i], 0, If[i == 2, 1, b[Abs[n-Prime[i]], i-1] + b[n+Prime[i], i-1]]];
    a[n_] := b[4, 2n];
    Array[a, 30] (* Jean-François Alcover, Nov 07 2020, after Alois P. Heinz *)
  • PARI
    A261062(n,rhs=-1,firstprime=2)={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.

Formula

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

Extensions

a(14)-a(29) from Alois P. Heinz, Aug 08 2015

A292698 Number of solutions to 3 +- 7 +- 13 +- 19 +- ... +- prime(4*n) = 0.

Original entry on oeis.org

0, 0, 0, 1, 2, 8, 27, 83, 292, 944, 3279, 11291, 38992, 138066, 490248, 1757360, 6347321, 22998089, 83780199, 306819363, 1128999790, 4174251748, 15507225620, 57767819903, 215327188611, 803901214851, 3013081897103, 11331883386143, 42737620941612
Offset: 1

Views

Author

Seiichi Manyama, Sep 21 2017

Keywords

Examples

			For n = 4 the solution is 3 - 7 - 13 + 19 - 29 + 37 + 43 - 53 = 0.
		

Crossrefs

Programs

  • Maple
    s:= proc(n) s(n):= `if`(n=0, 0, ithprime(2*n)+s(n-1)) end:
    b:= proc(n, i) option remember; `if`(n>s(i), 0, `if`(i=0, 1,
          (p-> b(n+p, i-1)+b(abs(n-p), i-1))(ithprime(2*i))))
        end:
    a:= n-> b(0, 2*n)/2:
    seq(a(n), n=1..30);  # Alois P. Heinz, Sep 21 2017
  • Mathematica
    s[n_] := s[n] = If[n == 0, 0, Prime[2n] + s[n-1]];
    b[n_, i_] := b[n, i] = If[n > s[i], 0, If[i == 0, 1,
         With[{p = Prime[2i]}, b[n+p, i-1] + b[Abs[n-p], i-1]]]];
    a[n_] := b[0, 2n]/2;
    Table[a[n], {n, 1, 30}] (* Jean-François Alcover, Apr 30 2022, after Alois P. Heinz *)
  • PARI
    {a(n) = 1/2*polcoeff(prod(k=1, 2*n, x^prime(2*k)+1/x^prime(2*k)), 0)}

Formula

Constant term in the expansion of 1/2 * Product_{k=1..2*n} (x^prime(2*k) + 1/x^prime(2*k)).

A292699 Number of solutions to 5 +- 11 +- 17 +- 23 +- ... +- prime(4*n+1) = 0.

Original entry on oeis.org

0, 1, 1, 2, 2, 5, 28, 102, 242, 835, 3381, 10115, 39415, 138555, 465778, 1741167, 6081563, 22156403, 81090107, 301185788, 1098440558, 4071519963, 15235221189, 56764430821, 211797564907, 790029575790, 2962705350767, 11154931819979, 42097079364709
Offset: 1

Views

Author

Seiichi Manyama, Sep 21 2017

Keywords

Examples

			For n=2 the solution is 5-11-17+23 = 0.
For n=3 the solution is 5+11+17-23+31-41 = 0.
For n=4 the 2 solutions are 5-11+17+23+31+41-47-59 = 0 and 5+11-17+23+31-41+47-59 = 0.
		

Crossrefs

Programs

  • Maple
    s:= proc(n) s(n):= `if`(n=0, 0, ithprime(2*n+1)+s(n-1)) end:
    b:= proc(n, i) option remember; `if`(n>s(i), 0, `if`(i=0, 1,
          (p-> b(n+p, i-1)+b(abs(n-p), i-1))(ithprime(2*i+1))))
        end:
    a:= n-> b(0, 2*n)/2:
    seq(a(n), n=1..30);  # Alois P. Heinz, Sep 21 2017
  • Mathematica
    s[n_] := s[n] = If[n == 0, 0, Prime[2n+1] + s[n-1]];
    b[n_, i_] := b[n, i] = If[n > s[i], 0, If[i == 0, 1,
         With[{p = Prime[2i+1]}, b[n+p, i-1] + b[Abs[n-p], i-1]]]];
    a[n_] := b[0, 2n]/2;
    Table[a[n], {n, 1, 30}] (* Jean-François Alcover, Apr 30 2022, after Alois P. Heinz *)
  • PARI
    {a(n) = 1/2*polcoeff(prod(k=1, 2*n, x^prime(2*k+1)+1/x^prime(2*k+1)), 0)}

Formula

Constant term in the expansion of 1/2 * Product_{k=1..2*n} (x^prime(2*k+1) + 1/x^prime(2*k+1)).

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

A215222 Number of solutions to n = Sum_{i=1..pi(n-1)} c(i)*p(i) with c(i) in {-1,0,1}, p(n) = n-th prime and pi = A000720.

Original entry on oeis.org

0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 1, 5, 5, 13, 12, 11, 11, 29, 28, 74, 73, 71, 69, 184, 182, 176, 173, 170, 164, 446, 437, 1180, 1165, 1147, 1137, 1115, 1104, 2984, 2949, 2919, 2887, 7841, 7778, 21331, 21184, 21029, 20861, 57465, 57114, 56741, 56372, 55997, 55610
Offset: 1

Views

Author

Alois P. Heinz, Aug 06 2012

Keywords

Examples

			a(5) = 1: 5 = 3+2.
a(6) = 1: 6 = 5+3-2.
a(7) = 1: 7 = 5+2.
a(8) = 2: 8 = 5+3 = 7+3-2.
a(9) = 2: 9 = 7+2 = 7+5-3.
a(10) = 3: 10 = 5+3+2 = 7+3 = 7+5-2.
a(11) = 1: 11 = 7+5-3+2.
a(12) = 5: 12 = 7+3+2 = 7+5 = 11+3-2 = 11-7+5+3 = 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(n, numtheory[pi](n-1)):
    seq(a(n), n=1..60);
  • 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, i-1] + b[n+Prime[i], i-1] + b[Abs[n-Prime[i]], i-1]]]; a[n_] := b[n, PrimePi[n-1]]; Table[a[n], {n, 1, 60}] (* Jean-François Alcover, Dec 03 2014, after Alois P. Heinz *)

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

Original entry on oeis.org

1, 0, 1, 0, 1, 0, 1, 1, 4, 5, 9, 15, 26, 45, 77, 137, 243, 434, 774, 1408, 2554, 4667, 8627, 15927, 29559, 54867, 101688, 189425, 355315, 668598, 1264180, 2395462, 4506221, 8507311, 16084405, 30545142, 57898862, 110199367, 209957460, 400430494, 765333684
Offset: 0

Views

Author

Ilya Gutkovskiy, Jan 29 2022

Keywords

Crossrefs

Programs

  • Mathematica
    Table[SeriesCoefficient[Product[x^Prime[k] + 1/x^Prime[k], {k, n - 1}], {x, 0, n}], {n, 0, 40}] (* Stefano Spezia, Jan 30 2022 *)
  • Python
    from sympy import sieve, primerange
    from functools import cache
    @cache
    def b(n, i):
        maxsum = 0 if i < 2 else sum(p for p in primerange(2, sieve[i-1]+1))
        if n > maxsum: return 0
        if i < 2: return 1
        return b(n+sieve[i-1], i-1) + b(abs(n-sieve[i-1]), i-1)
    def a(n): return b(n, n)
    print([a(n) for n in range(41)]) # Michael S. Branicky, Jan 29 2022

Formula

a(n) = [x^n] Product_{k=1..n-1} (x^prime(k) + 1/x^prime(k)).

A350881 a(n) is the constant term in expansion of Product_{k=1..n} (x^prime(k) + 1/x^prime(k))^2.

Original entry on oeis.org

1, 2, 4, 10, 24, 50, 140, 368, 1152, 3682, 11784, 39902, 134612, 463066, 1635092, 5818384, 20684072, 73693068, 266943648, 967762792, 3533666568, 13036452946, 48102671884, 178315730764, 661567489568, 2450447537226, 9123572154720, 34201574126260
Offset: 0

Views

Author

Ilya Gutkovskiy, Jan 20 2022

Keywords

Crossrefs

Programs

  • Maple
    p:= proc(n) option remember; `if`(n=0, 1,
          p(n-1)*(x^ithprime(n)+1/x^ithprime(n))^2)
        end:
    a:= n-> coeff(p(n), x, 0):
    seq(a(n), n=0..30);  # Alois P. Heinz, Jan 26 2022
  • Mathematica
    p[n_] := p[n] = If[n == 0, 1, p[n - 1]*(x^Prime[n] + 1/x^Prime[n])^2];
    a[n_] := Coefficient[p[n], x, 0];
    Table[a[n], {n, 0, 30}] (* Jean-François Alcover, Mar 01 2022, after Alois P. Heinz *)
  • PARI
    a(n) = polcoef (prod(k=1, n, (x^prime(k) + 1/x^prime(k))^2), 0); \\ Michel Marcus, Jan 21 2022
Previous Showing 21-30 of 36 results. Next