The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation. Hints (Greetings from The On-Line Encyclopedia of Integer Sequences!)
 A008347 a(n) = Sum_{i=0..n-1} (-1)^i * prime(n-i). 28

%I

%S 0,2,1,4,3,8,5,12,7,16,13,18,19,22,21,26,27,32,29,38,33,40,39,44,45,

%T 52,49,54,53,56,57,70,61,76,63,86,65,92,71,96,77,102,79,112,81,116,83,

%U 128,95,132,97,136,103,138,113,144,119,150,121,156,125,158,135,172,139,174,143

%N a(n) = Sum_{i=0..n-1} (-1)^i * prime(n-i).

%C Define the sequence b(n) by b(1) = 1; b(n) = 1 - (prime(n-1)/prime(n))*b(n-1) if n > 1. Then b(n) = a(n)/prime(n). Does lim b(n) exist? If so, it must equal 1/2. - _Joseph L. Pe_, Feb 17 2003

%C This sequence contains no duplicate values; after the initial 0, 2, the parity alternates, and a(n+2) > a(n). Do even and odd values trade the lead infinitely often (as would be expected if we model their difference as a random walk)? - _Franklin T. Adams-Watters_, Jan 25 2010

%C Conjecture: For any m = 1, 2, 3, ... and r = 0, ..., m - 1, there are infinitely many positive integers n with a(n) == r (mod m). - _Zhi-Wei Sun_, Feb 27 2013

%C From _Zhi-Wei Sun_, May 18 2013: (Start)

%C Conjectures:

%C (i) The sequence a(1), a(2), a(3), ... contains infinitely many Sophie Germain primes (A005384). (For example, a(1) = 2, a(4) = 3, a(6) = 5, a(18) = 29, a(28) = 53, a(46) = 83, a(54) = 113 and a(86) = 191 are Sophie Germain primes.) Also, there are infinitely many positive integers n such that a(n) - 1 and a(n) + 1 are twin primes. (Such integers n are 3, 7, 11, 41, 53, 57, 69, 95, 147, 191, 253, ....)

%C (ii) For each non-constant integer-valued polynomial P(x) with positive leading coefficient, there are infinitely many positive integers n such that a(n) = P(x) for some positive integer x. (For example, a(2) = 1^2, a(3) = 2^2, a(9) = 4^2, a(26) = 7^2, a(44) = 9^2, a(55) = 12^2 and a(58) = 11^2 are squares.)

%C (iii) The only powers of two in the current sequence are a(1) = 2, a(2) = 1, a(3) = 4, a(5) = 8, a(9) = 16, a(17) = 32, a(47) = 128, and a(165) = 512.

%C (iv) The only solutions to the equation a(n) = m! are (m,n) = (1, 2), (2, 1), (8, 7843). [False!] (End)

%C Conjecture: For any n > 9 we have a(n+1) < a(n-1)^(1+2/(n+2)). (This yields an upper bound for prime(n+1) - prime(n) in terms of prime(1), ..., prime(n-1). The conjecture has been verified for n up to 10^8.) - _Zhi-Wei Sun_, Jun 09 2013

%C a(n+2) - a(n) = A001223(n+1). - _Reinhard Zumkeller_, Feb 09 2015

%C Conjecture (iv) above is false since a(1379694977463) = 20922789888000 = 16!. - _Giovanni Resta_, Sep 04 2018

%C Conjecture: We have {a(m)+a(n): m,n>0} = {2,3,...}. Also, {a(m)-a(n): m,n>0} contains all the integers, and {a(m)/a(n): m,n>0} contains all the positive rational numbers. (I have noted that {a(m)/a(n): m,n = 1..60000} contains {a/b: a,b = 1..1000}.) - _Zhi-Wei Sun_, May 23 2019

%C Let d(n) = a(n) - a(n-1). Since a(n-1) = prime(n) - a(n), d(n) = 2*a(n) - prime(n). If lim inf a(n)/prime(n) = 1/2 as conjectured by Joseph L. Pe above holds, lim inf d(n)/prime(n) = 2*lim inf a(n)/prime(n) - 1 = 0. Numerical analysis of a(n) for n up to 6.5*10^7 shows that abs(d(n)) < 8*sqrt(prime(n)), and thus abs(d(n)) < O(sqrt(prime(n))) is conjectured. - _Ya-Ping Lu_, Aug 31 2020

%H N. J. A. Sloane, <a href="/A008347/b008347.txt">Table of n, a(n) for n = 0..30000</a> [Updated Dec 18 2019. First 2000 terms from T. D. Noe, first 10000 terms from Robert G. Wilson v]

%H Romeo Meštrovic, <a href="https://arxiv.org/abs/1805.11657">On the distribution of primes in the alternating sums of consecutive primes</a>, arXiv:1805.11657 [math.NT], 2018.

%H Zhi-Wei Sun, <a href="http://dx.doi.org/10.1016/j.jnt.2013.02.003">On functions taking only prime values</a>, J. Number Theory 133(2013), no.8, 2794-2812.

%H Zhi-Wei Sun, <a href="http://dx.doi.org/10.1017/S0004972712000986">On a sequence involving sums of primes</a>, Bull. Aust. Math. Soc. 88(2013), 197-205.

%F a(n) = prime(n) - a(n-1) for n>=1.

%F G.f: (x*b(x))/(1+x), where b(x) is the g.f. of A000040. - _Mario C. Enriquez_, Dec 10 2016

%F Meštrovic (2018), following Pillai, conjectures that

%F a(2k) = k*log k + k*loglog k - k + o(k) as k -> oo,

%F with a similar conjecture for a(2k+1). - _N. J. A. Sloane_, Dec 21 2019

%p A008347 := proc(n) options remember; if n = 0 then 0 else abs(A008347(n-1)-ithprime(n)); fi; end;

%t Join[{0},Abs[Accumulate[Times@@@Partition[Riffle[Prime[Range],{1,-1}], 2]]]] (* _Harvey P. Dale_, Dec 11 2011 *)

%t f[n_] := Abs@ Sum[(-1)^k Prime[k], {k, n - 1}]; Array[f, 70] (* _Robert G. Wilson v_, Oct 08 2013 *)

%t a = 0; a[n_] := a[n] = Prime[n] - a[n - 1]; Array[a, 70, 0] (* _Robert G. Wilson v_, Oct 16 2013 *)

%o (Haskell)

%o a008347 n = a008347_list !! n

%o a008347_list = 0 : zipWith (-) a000040_list a008347_list

%o -- _Reinhard Zumkeller_, Feb 09 2015

%o (PARI) a(n)=abs(sum(i=1,n,(-1)^i*prime(i))) \\ _Charles R Greathouse IV_, Apr 29 2015

%o (MAGMA)  cat [&+[ (-1)^k * NthPrime(n-k): k in [0..n-1]]: n in [1..70]]; // _Vincenzo Librandi_, May 26 2019

%Y Complement is in A226913.

%Y Cf. A000040, A001223, A005384, A007504, A181901.

%K nonn

%O 0,2

%A _N. J. A. Sloane_ and _J. H. Conway_

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.

Last modified April 11 14:44 EDT 2021. Contains 342886 sequences. (Running on oeis4.)