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!)
 A050936 Sum of two or more consecutive prime numbers. 21

%I

%S 5,8,10,12,15,17,18,23,24,26,28,30,31,36,39,41,42,48,49,52,53,56,58,

%T 59,60,67,68,71,72,75,77,78,83,84,88,90,95,97,98,100,101,102,109,112,

%U 119,120,121,124,127,128,129,131,132,138,139,143,144,150,152,155,156,158,159,160,161,162

%N Sum of two or more consecutive prime numbers.

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

%H P. De Geest, <a href="http://www.worldofnumbers.com/em122.htm">WONplate 122</a>

%H C. Rivera, <a href="http://www.primepuzzles.net/puzzles/puzz_046.htm">Puzzle 46</a>

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/PrimeSums.html">Prime Sums</a>

%e E.g., 5 = (2 + 3) or (#2,2).

%e 2+3 = 5, 3+5 = 8, 2+3+5 = 10, 7+5 = 12, 3+5+7 = 15, etc.

%p # uses code of A084143

%p isA050936 := proc(n::integer)

%p if A084143(n) >= 1 then

%p true;

%p else

%p false;

%p end if;

%p end proc:

%p for n from 1 to 300 do

%p if isA050936(n) then

%p printf("%d,",n);

%p end if;

%p end do: # _R. J. Mathar_, Aug 19 2020

%t lst={};Do[p=Prime[n];Do[p=p+Prime[k];AppendTo[lst, p], {k, n+1, 2*10^2}], {n, 2*10^2}];Take[Union[lst], 10^2] (* _Vladimir Joseph Stephan Orlovsky_, Aug 21 2008 *)

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

%t lmt = 150; p = Prime@ Range@ PrimePi@ lmt; t = Table[0, {lmt}]; Do[s = 0; j = i+1; While[s = s + p[[j]]; s <= lmt, t[[s]]++; j++], {i, Length@ p}]; Select[ Range@ lmt, t[[#]] > 0 &] (* _Robert G. Wilson v_ *)

%t Module[{nn=70,prs},prs=Prime[Range[nn]];Take[Union[Flatten[Table[Total/@ Partition[prs,i,1],{i,2,nn}]]],nn]] (* _Harvey P. Dale_, Nov 13 2013 *)

%o import Data.Set (empty, findMin, deleteMin, insert)

%o import qualified Data.Set as Set (null)

%o a050936 n = a050936_list !! (n-1)

%o a050936_list = f empty [2] 2 \$ tail a000040_list where

%o f s bs c (p:ps)

%o | Set.null s || head bs <= m = f (foldl (flip insert) s bs') bs' p ps

%o | otherwise = m : f (deleteMin s) bs c (p:ps)

%o where m = findMin s

%o bs' = map (+ p) (c : bs)

%o -- _Reinhard Zumkeller_, Aug 26 2011

%o (PARI) is(n)=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 Cf. A067372 up to A067381, A054996, A000040.

%Y A084143(a(n)) > 0, complement of A087072.

%Y Cf. A034707, A054845, A097889.

%K nice,nonn,easy

%O 1,1

%A _G. L. Honaker, Jr._, Dec 31 1999

%E More terms from _David W. Wilson_, Jan 13 2000

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 September 20 20:02 EDT 2020. Contains 337265 sequences. (Running on oeis4.)