A050936 Sum of two or more consecutive prime numbers.
5, 8, 10, 12, 15, 17, 18, 23, 24, 26, 28, 30, 31, 36, 39, 41, 42, 48, 49, 52, 53, 56, 58, 59, 60, 67, 68, 71, 72, 75, 77, 78, 83, 84, 88, 90, 95, 97, 98, 100, 101, 102, 109, 112, 119, 120, 121, 124, 127, 128, 129, 131, 132, 138, 139, 143, 144, 150, 152, 155, 156, 158, 159, 160, 161, 162
Offset: 1
Examples
E.g., 5 = (2 + 3) or (#2,2). 2+3 = 5, 3+5 = 8, 2+3+5 = 10, 7+5 = 12, 3+5+7 = 15, etc.
Links
- T. D. Noe, Table of n, a(n) for n = 1..10000
- Patrick De Geest, WONplate 122
- Carlos Rivera, Puzzle 46. Primes expressible as sum of consecutive primes in K ways, The Prime Puzzles and Problems Connection.
- Eric Weisstein's World of Mathematics, Prime Sums
Crossrefs
Programs
-
Haskell
import Data.Set (empty, findMin, deleteMin, insert) import qualified Data.Set as Set (null) a050936 n = a050936_list !! (n-1) a050936_list = f empty [2] 2 $ tail a000040_list where f s bs c (p:ps) | Set.null s || head bs <= m = f (foldl (flip insert) s bs') bs' p ps | otherwise = m : f (deleteMin s) bs c (p:ps) where m = findMin s bs' = map (+ p) (c : bs) -- Reinhard Zumkeller, Aug 26 2011
-
Maple
# uses code of A084143 isA050936 := proc(n::integer) if A084143(n) >= 1 then true; else false; end if; end proc: for n from 1 to 300 do if isA050936(n) then printf("%d,",n); end if; end do: # R. J. Mathar, Aug 19 2020
-
Mathematica
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 *) 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 *) 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 *) 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 *)
-
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
Charles R Greathouse IV, May 05 2016 -
PARI
list(lim)=my(v=List(),s,n=1,p); while(1, p=2; s=vecsum(primes(n++)); if(s>lim,return(Set(v))); listput(v,s); forprime(q=prime(n+1),, s+=q-p; if(s>lim,break); listput(v,s); p=nextprime(p+1))); \\ Charles R Greathouse IV, Nov 24 2021
Extensions
More terms from David W. Wilson, Jan 13 2000