login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A008347 a(n) = Sum_{i=0..n-1} (-1)^i * prime(n-i). 30
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, 52, 49, 54, 53, 56, 57, 70, 61, 76, 63, 86, 65, 92, 71, 96, 77, 102, 79, 112, 81, 116, 83, 128, 95, 132, 97, 136, 103, 138, 113, 144, 119, 150, 121, 156, 125, 158, 135, 172, 139, 174, 143 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,2
COMMENTS
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
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
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
From Zhi-Wei Sun, May 18 2013: (Start)
Conjectures:
(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, ....)
(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.)
(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.
(iv) The only solutions to the equation a(n) = m! are (m,n) = (1, 2), (2, 1), (8, 7843). [False!] (End)
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
Conjecture (iv) above is false since a(1379694977463) = 20922789888000 = 16!. - Giovanni Resta, Sep 04 2018
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
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 10^9 shows that abs(d(n))/sqrt(prime(n)) < 15, and thus abs(d(n)) = O(sqrt(prime(n))) is conjectured. - Ya-Ping Lu, Aug 31 2020
LINKS
N. J. A. Sloane, Table of n, a(n) for n = 0..30000 (updated Dec 18 2019; terms 0..2000 from T. D. Noe, terms 2001..10000 from Robert G. Wilson v)
Romeo Meštrovic, On the distribution of primes in the alternating sums of consecutive primes, arXiv:1805.11657 [math.NT], 2018.
Zhi-Wei Sun, On functions taking only prime values, J. Number Theory 133(2013), no.8, 2794-2812.
Zhi-Wei Sun, On a sequence involving sums of primes, Bull. Aust. Math. Soc. 88(2013), 197-205.
FORMULA
a(n) = prime(n) - a(n-1) for n >= 1.
a(n+2) - a(n) = A001223(n+1). - Reinhard Zumkeller, Feb 09 2015
G.f: (x*b(x))/(1+x), where b(x) is the g.f. of A000040. - Mario C. Enriquez, Dec 10 2016
Meštrovic (2018), following Pillai, conjectures that
a(2k) = k*log k + k*loglog k - k + o(k) as k -> oo,
with a similar conjecture for a(2k+1). - N. J. A. Sloane, Dec 21 2019
MAPLE
A008347 := proc(n) options remember; if n = 0 then 0 else abs(A008347(n-1)-ithprime(n)); fi; end;
MATHEMATICA
Join[{0}, Abs[Accumulate[Times@@@Partition[Riffle[Prime[Range[80]], {1, -1}], 2]]]] (* Harvey P. Dale, Dec 11 2011 *)
f[n_] := Abs@ Sum[(-1)^k Prime[k], {k, n - 1}]; Array[f, 70] (* Robert G. Wilson v, Oct 08 2013 *)
a[0] = 0; a[n_] := a[n] = Prime[n] - a[n - 1]; Array[a, 70, 0] (* Robert G. Wilson v, Oct 16 2013 *)
FoldList[#2 - # &, 0, Array[Prime, 30]] (* Horst H. Manninger, Oct 29 2021 *)
PROG
(Haskell)
a008347 n = a008347_list !! n
a008347_list = 0 : zipWith (-) a000040_list a008347_list
-- Reinhard Zumkeller, Feb 09 2015
(PARI) a(n)=abs(sum(i=1, n, (-1)^i*prime(i))) \\ Charles R Greathouse IV, Apr 29 2015
(Magma) [0] cat [&+[ (-1)^k * NthPrime(n-k): k in [0..n-1]]: n in [1..70]]; // Vincenzo Librandi, May 26 2019
(Python)
from sympy import nextprime
p = a = 0; L = [a]
for n in range(1, 67): p = nextprime(p); a = p - a; L.append(a)
print(*L, sep = ", ") # Ya-Ping Lu, May 07 2023
CROSSREFS
Complement is in A226913.
Sequence in context: A281878 A106625 A275902 * A112387 A370727 A193174
KEYWORD
nonn
AUTHOR
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified June 29 18:23 EDT 2024. Contains 373855 sequences. (Running on oeis4.)