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!)
A235431 The smallest positive number that must be added to or subtracted from the sum of the first n primes in order to get a prime. 1
1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 1, 2, 3, 4, 3, 4, 1, 2, 5, 2, 1, 4, 1, 4, 1, 2, 3, 4, 5, 2, 3, 2, 5, 2, 1, 2, 1, 2, 3, 2, 1, 2, 1, 2, 3, 2, 1, 2, 1, 10, 1, 4, 11, 2, 1, 6 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,2
COMMENTS
The primes in A013918 would have associated a(n)=0 if not for the qualifier "positive" in the definition.
The sum of the first n primes appears to be close to a prime. For illustration, the maximum for a(n) among the first 5 million terms is a(808500) = 218.
See A013916 for the above mentioned indices, numbers n such that the sum of the first n primes is prime. - M. F. Hasler, Jan 20 2014
LINKS
FORMULA
Algorithm:
Let S be the sum of the first n primes;
initially, let k=1;
increment k while neither S-k nor S+k is prime;
return a(n)=k.
a(n) = min(A013632(A007504(n)), A049711(A007504(n))). - M. F. Hasler, Jan 20 2014
EXAMPLE
Example:
The sum of the first 9 primes is 100, and by adding 1 we get 101. Since 101 is a prime, a(9) = 1.
The sum of the first 10 primes is 129, since 129 - 2 = prime(31) = 127 or 129 + 2 = prime(32) = 131, a(10) = 2.
The sum of the first 129 primes minus 1 is a prime, this is 42468 - 1 = prime(4443), so a(129) = 1.
PROG
(PARI) a(n)=my(u=sum(j=1, n, prime(j)), k=1); while(!(isprime(u+k)||isprime(u-k)), k++); k
CROSSREFS
Sequence in context: A214069 A167969 A245192 * A354599 A303536 A259656
KEYWORD
nonn,easy,hear
AUTHOR
R. J. Cano, Jan 17 2014
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 April 24 22:17 EDT 2024. Contains 371964 sequences. (Running on oeis4.)