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!)
A034707 Numbers that are sums (of a nonempty sequence) of consecutive primes. 21

%I #35 Sep 20 2023 16:45:48

%S 2,3,5,7,8,10,11,12,13,15,17,18,19,23,24,26,28,29,30,31,36,37,39,41,

%T 42,43,47,48,49,52,53,56,58,59,60,61,67,68,71,72,73,75,77,78,79,83,84,

%U 88,89,90,95,97,98,100,101,102,103,107,109,112,113,119,120,121,124,127

%N Numbers that are sums (of a nonempty sequence) of consecutive primes.

%C A050936 is a subsequence (which still includes primes, embodied by A067377). - _Enoch Haga_, Jun 16 2002, _R. J. Mathar_, Oct 10 2010

%H T. D. Noe, <a href="/A034707/b034707.txt">Table of n, a(n) for n = 1..10000</a>

%H Leo Moser, <a href="https://doi.org/10.4153/CMB-1963-013-1">On the Sum of Consecutive Primes</a>. Canad. Math. Bull. 6 (1963), 159-161.

%H Janyarak Tongsomporn, Saeree Wananiyaku, and Jörn Steuding, <a href="http://math.colgate.edu/~integers/w9/w9.pdf">Sums of consecutive prime squares</a>, Integers (2022) Vol. 22, #A9.

%F A054845(a(n)) > 0. - _Ray Chandler_, Sep 20 2023

%t f[n_] := Block[{len = PrimePi@ n}, p = Prime@ Range@ len; Count[ Flatten[ Table[ p[[i ;; j]], {i, len}, {j, i, len}],1], q_ /; Total@ q == n]]; Select[ Range@ 1000, f@ # > 0 &] (* Or quicker for a larger range *)

%t lmt = 10000; p = Prime@ Range@ PrimePi@ lmt; t = Table[0, {lmt}]; Do[s = 0; j = i; While[s = s + p[[j]]; s <= lmt, t[[s]]++; j++], {i, Length@ p}]; Select[ Range@ lmt, t[[#]] > 0 &]

%t upto=200;Select[Union[Flatten[Table[ Total/@Partition[Prime[ Range[ PrimePi[ upto]]],n,1],{n,upto-1}]]],#<=upto&] (* _Harvey P. Dale_, Jul 15 2011 *)

%o (PARI) is(n)=if(isprime(n), return(1)); my(v,m=1,t); while(1, v=vector(m++); v[m\2]=precprime(n\m); for(i=m\2+1,m,v[i]=nextprime(v[i-1]+1)); forstep(i=m\2-1,1,-1,v[i]=precprime(v[i+1]-1)); if(v[1]==0, return(0)); t=vecsum(v); if (t==n, return(1)); if(t>n, while(t>n, t-=v[m]; v=concat(precprime(v[1]-1), v[1..m-1]); t+=v[1]), while(t<n, t-=v[1]; v=concat(v[2..m], nextprime(v[m]+1)); t+=v[m])); if(v[1]==0, return(0)); if(t==n, return(1))) \\ _Charles R Greathouse IV_, May 05 2016

%Y Complement is A050940.

%Y Cf. A050936, A054845.

%K nonn,nice,easy

%O 1,1

%A _Erich Friedman_

%E Updated a misleading comment. - _R. J. Mathar_, Oct 10 2010

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 19 16:52 EDT 2024. Contains 371794 sequences. (Running on oeis4.)