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.
%I A235431 #45 May 11 2025 23:48:01 %S A235431 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, %T A235431 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 %N 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. %C A235431 The primes in A013918 would have associated a(n)=0 if not for the qualifier "positive" in the definition. %C A235431 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. %C A235431 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 %H A235431 R. J. Cano, <a href="/A235431/b235431.txt">Table of n, a(n) for n = 1..10000</a> %F A235431 Algorithm: %F A235431 Let S be the sum of the first n primes; %F A235431 initially, let k=1; %F A235431 increment k while neither S-k nor S+k is prime; %F A235431 return a(n)=k. %F A235431 a(n) = min(A013632(A007504(n)), A049711(A007504(n))). - _M. F. Hasler_, Jan 20 2014 %e A235431 The sum of the first 9 primes is 100, and by adding 1 we get 101. Since 101 is a prime, a(9) = 1. %e A235431 The sum of the first 10 primes is 129, since 129 - 2 = prime(31) = 127 or 129 + 2 = prime(32) = 131, a(10) = 2. %e A235431 The sum of the first 129 primes minus 1 is a prime, this is 42468 - 1 = prime(4443), so a(129) = 1. %o A235431 (PARI) a(n)=my(u=sum(j=1,n,prime(j)),k=1);while(!(isprime(u+k)||isprime(u-k)),k++);k %Y A235431 Cf. A007504, A101301. %K A235431 nonn,easy,hear %O A235431 1,2 %A A235431 _R. J. Cano_, Jan 17 2014