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 30 results.

A175117 Numbers k such that Sum_(i=1..k) prime(i)*(-1)^(i+1) is a square.

Original entry on oeis.org

3, 9, 55, 181, 215, 459, 1361, 1417, 1623, 2047, 2445, 4685, 6687, 7353, 7785, 7925, 8489, 10333, 10515, 11179, 14087, 15227, 15829
Offset: 1

Views

Author

Ctibor O. Zizka, Feb 14 2010

Keywords

Comments

Numbers k such that (-1)^k*A008347(k) is a perfect square. - R. J. Mathar, Feb 21 2010

Examples

			2 - 3 + 5 = 4, thus a(1)=3;
2 - 3 + 5 - 7 + 11 - 13 + 17 - 19 + 23 = 16, thus a(2)=9.
		

Crossrefs

Cf. A000040.

Programs

Extensions

Six more terms from R. J. Mathar, Feb 21 2010

A213325 Number of ways to write n = q + sum_{k=1}^m(-1)^{m-k}p_k, where p_k is the k-th prime, and q is a practical number with q-4 and q+4 also practical.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 1, 2, 2, 2, 1, 2, 3, 3, 1, 2, 4, 3, 2, 3, 4, 4, 3, 3, 4, 4, 4, 4, 4, 5, 4, 4, 5, 5, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, 3, 3, 5, 3, 2, 4, 6, 4, 3, 6, 7, 2, 2, 6, 6, 2, 2, 5, 7, 2, 2, 5, 6, 3, 3, 3, 7, 3, 2, 3, 7, 4, 5, 4, 8, 2, 5, 4, 6, 2, 4, 2, 5, 3, 5, 4
Offset: 1

Views

Author

Zhi-Wei Sun, Mar 03 2013

Keywords

Comments

Conjecture: a(n)>0 for all n>8.
The author has verified this for n up to 5*10^6.

Examples

			a(11)=1 since 11=8+(7-5+3-2) with 4, 8, 12 all practical.
		

Crossrefs

Programs

  • Mathematica
    f[n_]:=f[n]=FactorInteger[n]
    Pow[n_,i_]:=Pow[n,i]=Part[Part[f[n],i],1]^(Part[Part[f[n],i],2])
    Con[n_]:=Con[n]=Sum[If[Part[Part[f[n],s+1],1]<=DivisorSigma[1,Product[Pow[n,i],{i,1,s}]]+1,0,1],{s,1,Length[f[n]]-1}]
    pr[n_]:=pr[n]=n>0&&(n<3||Mod[n,2]+Con[n]==0)
    q[n_]:=q[n]=pr[n-4]==True&&pr[n]==True&&pr[n+4]==True
    s[0_]:=0
    s[n_]:=s[n]=Prime[n]-s[n-1]
    a[n_]:=a[n]=Sum[If[n-s[m]>0&&q[n-s[m]],1,0],{m,1,n}]
    Table[a[n],{n,1,100}]

A226743 Number of alternating sums of consecutive primes with result 2n-1.

Original entry on oeis.org

1, 1, 2, 2, 3, 1, 2, 3, 2, 3, 5, 4, 4, 4, 5, 4, 5, 5, 4, 6, 5, 4, 9, 5, 5, 7, 6, 6, 10, 7, 9, 5, 11, 6, 6, 9, 8, 8, 9, 9, 9, 12, 8, 8, 10, 7, 9, 9, 12, 11, 8, 11, 12, 6, 10, 6, 8, 14, 10, 12, 13, 10, 11, 5, 11, 9, 11, 16, 11, 11, 14, 10, 10, 13, 10, 17, 12, 11, 18, 13, 13, 11, 18, 11, 13, 12, 14, 16, 17, 14, 10, 15, 11, 12
Offset: 1

Views

Author

Ralf Stephan, Sep 01 2013

Keywords

Comments

Since A008347 has no duplicate values, a(n) must be finite. This is not true for even results of the sum.
Sums of a single term are not included. - Robert Israel, Feb 06 2025

Examples

			n=5: 11-7+5=2*5-1, 13-11+7=2*5-1, 19-17+13-11+7-5+3=2*5-1, so a(5)=3.
		

Crossrefs

Cf. A084143.

Programs

  • Maple
    N:= 100: M:= 2*N-1: # for a(1)..a(N)
    p:= 1: b:= 0: B:= NULL:
    for i from 1 do
      p:= nextprime(p);
      b:= b + (-1)^i*p;
      B:= B,b;
      if b > M then nB:= i; break fi;
    od:
    V:= Vector(M):
    for j from 2 to nB by 2 while B[j] <= M do V[B[j]]:= 1 od:
    for i from 1 to nB do
      for j from i+3 to nB by 2 do
        r:= abs(B[j]-B[i]);
        if r <= M then V[r]:= V[r]+1 else break fi;
    od od:
    seq(V[i],i=1..M,2); # Robert Israel, Feb 06 2025
  • PARI
    vb=vecsmall(500);for(k=2,1000,forstep(l=k-1,1,-1,t=sum(i=l,k,prime(i)*(-1)^(k-i));if(t<500,vb[t]=vb[t]+1)))

A233809 a(n) = Sum_{k=1..n} prime(k) * s(k), where s(k) = (-1)^(floor(k/2)).

Original entry on oeis.org

2, -1, -6, 1, 12, -1, -18, 1, 24, -5, -36, 1, 42, -1, -48, 5, 64, 3, -64, 7, 80, 1, -82, 7, 104, 3, -100, 7, 116, 3, -124, 7, 144, 5, -144, 7, 164, 1, -166, 7, 186, 5, -186, 7, 204, 5, -206, 17, 244, 15, -218, 21, 262, 11, -246, 17, 286, 15, -262
Offset: 1

Views

Author

Jon Perry, Dec 16 2013

Keywords

Comments

s(k) starts +1, -1, -1, +1, +1, -1, -1, ...

Examples

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

Crossrefs

Cf. A130642 (a(n) = -1), A130643 (a(n) = 1). - Michel Marcus, Aug 06 2017

Programs

  • Magma
    [&+[NthPrime(k)*(-1)^(Floor(k/2)): k in [1..n]]: n in [1..60]]; // Vincenzo Librandi, Aug 07 2017
  • Mathematica
    f[n_] := Sum[(-1)^Floor[k/2]*Prime[k], {k, n}]; Array[f, 60] (* Robert G. Wilson v, Aug 06 2017 *)
  • PARI
    s(k) = (-1)^(floor(k/2));
    a(n) = sum(k=1,n,s(k)*prime(k));
    \\ Joerg Arndt, Aug 06 2017
    

Extensions

Name corrected by Joerg Arndt, Aug 06 2017

A242188 a(n) = Sum_{i=1..n} (-1)^(i+1) prime(i)^3.

Original entry on oeis.org

0, 8, -19, 106, -237, 1094, -1103, 3810, -3049, 9118, -15271, 14520, -36133, 32788, -46719, 57104, -91773, 113606, -113375, 187388, -170523, 218494, -274545, 297242, -407727, 504946
Offset: 0

Views

Author

Timothy Varghese, May 22 2014

Keywords

Comments

For n even this is the negative of the sum of (3^3 - 2^3) + (7^3 - 5^3) + .. (prime(n)^3 - prime(n-1)^3). But this is half of the terms in the sum of (3^3 - 2^3) + (5^3 - 3^3) + (7^3 - 5^3) + ... + (prime(n)^3 - prime(n-1)^3) which has a sum that telescopes to prime(n)^3 - 8. Thus a good estimate of a(n) (half the terms) is prime(n)^3/2 (half the square of the n-th prime) which works well. For odd n, add prime(n)^2 to the estimate for even n.

Crossrefs

Programs

  • Maple
    ListTools:-PartialSums([0,seq((-1)^(i+1)*ithprime(i)^3, i=1..40)]); # Robert Israel, Mar 09 2020
  • Mathematica
    Table[Sum[(-1)^(i+1) Prime[i]^3,{i,n}],{n,0,30}] (* Harvey P. Dale, May 16 2021 *)
  • PARI
    a(n) = sum(i=1, n, (-1)^(i+1)*prime(i)^3);

A339448 a(n) = (prime(n) - a(n-1)) mod 3; a(0)=0.

Original entry on oeis.org

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

Views

Author

Simon Strandgaard, Dec 05 2020

Keywords

Examples

			a(1) = ( 2 - 0) mod 3 = 2,
a(2) = ( 3 - 2) mod 3 = 1,
a(3) = ( 5 - 1) mod 3 = 1,
a(4) = ( 7 - 1) mod 3 = 0,
a(5) = (11 - 0) mod 3 = 2.
		

Crossrefs

Cf. A008347.

Programs

  • Mathematica
    a[0]=0; a[n_]:=Mod[Prime[n]-a[n-1],3]; Table[a[n],{n,0,85}] (* Stefano Spezia, Dec 05 2020 *)
  • Ruby
    require 'prime'
    values = [0]
    Prime.first(50).each do |prime|
        values << (prime-values[-1]) % 3
    end
    p values

A340867 a(n) = (prime(n) - a(n-1)) mod 4; a(0)=0.

Original entry on oeis.org

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

Views

Author

Simon Strandgaard, Jan 24 2021

Keywords

Examples

			a(1) = ( 2 - 0) mod 4 = 2,
a(2) = ( 3 - 2) mod 4 = 1,
a(3) = ( 5 - 1) mod 4 = 0,
a(4) = ( 7 - 0) mod 4 = 3,
a(5) = (11 - 3) mod 4 = 0.
		

Crossrefs

Programs

  • Mathematica
    a[0] = 0; a[n_] := a[n] = Mod[Prime[n] - a[n - 1], 4]; Array[a, 100, 0] (* Amiram Eldar, Jan 30 2021 *)
  • Ruby
    require 'prime'
    values = [0]
    Prime.first(50).each do |prime|
        values << (prime-values[-1]) % 4
    end
    p values

Formula

a(n) = A008347(n) mod 4.

A355726 a(n) = a(n-2) + prime(n-1) for a(0) = a(1) = 0.

Original entry on oeis.org

0, 0, 2, 3, 7, 10, 18, 23, 35, 42, 58, 71, 89, 108, 130, 151, 177, 204, 236, 265, 303, 336, 376, 415, 459, 504, 556, 605, 659, 712, 768, 825, 895, 956, 1032, 1095, 1181, 1246, 1338, 1409, 1505, 1582, 1684, 1763, 1875, 1956, 2072, 2155, 2283, 2378, 2510
Offset: 0

Views

Author

Paul Curtz, Jul 15 2022

Keywords

Crossrefs

Cf. A077131 (even bisection), A077126 (odd bisection).
Cf. A008347 (first differences), (-1)^n*A330547 (second differences).

Programs

  • Mathematica
    Join[{0},Accumulate[FoldList[#2-#1&,0,Prime[Range[100]]]]] (* Paolo Xausa, Dec 04 2023 *)

Formula

a(2*n) = A077131(n), for n>=1.
a(2*n+1) = A077126(n), for n>=1.

A376890 Alternating sum of twin primes (A001097).

Original entry on oeis.org

3, -2, 5, -6, 7, -10, 9, -20, 11, -30, 13, -46, 15, -56, 17, -84, 19, -88, 21, -116, 23, -126, 25, -154, 27, -164, 29, -168, 31, -196, 33, -206, 35, -234, 37, -244, 39, -272, 41, -306, 43, -376, 45, -386, 47, -414, 49, -472, 51, -518, 53, -546, 55, -562, 57, -584, 59, -600, 61, -748
Offset: 1

Views

Author

Ilya Gutkovskiy, Oct 08 2024

Keywords

Crossrefs

Programs

  • Maple
    T1:= select(t -> isprime(t) and isprime(t+2), [seq(i,i=5..1000,6)]):
    T:= map(t -> (-t, t+2), T1): T:= [3,op(T)]:
    ListTools:-PartialSums(T); # Robert Israel, Nov 08 2024

Formula

a(n) = Sum_{k=1..n} (-1)^(k+1) * A001097(k).
a(2*n-1) = 2*n+1.

A370831 Alternating sum of composites.

Original entry on oeis.org

4, 2, 6, 3, 7, 5, 9, 6, 10, 8, 12, 9, 13, 11, 14, 12, 15, 13, 17, 15, 18, 16, 19, 17, 21, 18, 22, 20, 24, 21, 25, 23, 26, 24, 27, 25, 29, 26, 30, 27, 31, 29, 33, 30, 34, 31, 35, 33, 36, 34, 38, 36, 39, 37, 40, 38, 42, 39, 43, 41, 44, 42, 45, 43, 47, 44, 48, 45, 49, 46
Offset: 1

Views

Author

James C. McMahon, Mar 02 2024

Keywords

Comments

Unlike equivalent sequence for primes, A008347, there are repeated terms.

Examples

			a(4) = 9 - 8 + 6 - 4 = 3.
		

Crossrefs

Programs

  • Mathematica
    Join[{4},a[1]=4;a[n_]:=ResourceFunction["Composite"][n] - a[n-1];Table[a[n],{n,2,70}]] (* or with signs *) R=70;a[1]=4;a[n_]:=a[n-1]-ResourceFunction["Composite"][n] *(-1)^n;Table[a[n],{n,70}]

Formula

a(n) = A002808(n) - a(n-1), for n>1.
Previous Showing 21-30 of 30 results.