This site is supported by donations to The OEIS Foundation.



(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A054845 Number of ways of representing n as the sum of one or more consecutive primes. 14


%S 0,0,1,1,0,2,0,1,1,0,1,1,1,1,0,1,0,2,1,1,0,0,0,2,1,0,1,0,1,1,1,2,0,0,

%T 0,0,2,1,0,1,0,3,1,1,0,0,0,1,1,1,0,0,1,2,0,0,1,0,1,2,2,1,0,0,0,0,0,2,

%U 1,0,0,2,2,1,0,1,0,1,1,1,0,0,0,3,1,0,0,0,1,1,2,0,0,0,0,1,0,2,1,0,2,2

%N Number of ways of representing n as the sum of one or more consecutive primes.

%C Moser shows that the average order of a(n) is log 2, that is, sum(i=1..n, a(i)) ~ n log 2. This shows that a(n) = 0 infinitely often (and with positive density); Moser asks if a(n) = 1 infinitely often, if a(n) = k is solvable for all k, whether these have positive density, and whether the sequence is bounded. - _Charles R Greathouse IV_, Mar 21 2011

%D R. K. Guy, Unsolved Problems In Number Theory, C2.

%H T. D. Noe, <a href="/A054845/b054845.txt">Table of n, a(n) for n = 0..10000</a>

%H Leo Moser, <a href="http://math.ca/10.4153/CMB-1963-013-1">Notes on number theory. III. On the sum of consecutive primes</a>, Canad. Math. Bull. 6 (1963), pp. 159-161.

%H C. Rivera, <a href="http://www.primepuzzles.net/problems/prob_009.htm">Problem 9</a>, Prime Puzzles.

%F G.f.: Sum_{i>=1} Sum_{j>=i} Product_{k=i..j} x^prime(k). - _Ilya Gutkovskiy_, Apr 18 2019

%e a(5)=2 because of 2+3 and 5. a(17)=2 because of 2+3+5+7 and 17.

%e 41 = 41 = 11+13+17 = 2+3+5+7+11+13, so a(41)=3.

%p A054845 := proc(n)

%p local a,mipri,npr,ps ;

%p a := 0 ;

%p for mipri from 1 do

%p for npr from 1 do

%p ps := add(ithprime(i),i=mipri..mipri+npr-1) ;

%p if ps = n then

%p a := a+1 ;

%p elif ps >n then

%p break;

%p end if;

%p end do:

%p if ithprime(mipri) > n then

%p break ;

%p end if;

%p end do:

%p a ;

%p end proc: # _R. J. Mathar_, Nov 27 2018

%t f[n_] := Block[{p = Prime@ Range@ PrimePi@ n}, len = Length@ p; Count[(Flatten[#, 1] &)[Table[ p[[i ;; j]], {i, len}, {j, i, len}]], q_ /; Total@ q == n]]; f[0] = 0; Array[f, 102, 0](* _Jean-Fran├žois Alcover_, Feb 16 2011 *) (* fixed by _Robert G. Wilson v_ *)

%t nn=100; p=Prime[Range[PrimePi[nn]]]; t=Table[0,{nn}]; Do[s=0; j=i; While[s=s+p[[j]]; s<=nn,t[[s]]++; j++], {i,Length[p]}]; Join[{0},t]

%o (PARI){/* program gives nn+1 values of a(n) for n=0..nn */

%o nn=2000;t=vector(nn+1);forprime(x=2,nn,s=x;

%o forprime(y=x+1,nn,if(s<=nn,t[s+1]++,break());s=s+y));t} \\ _Zak Seidov_, Feb 17 2011

%o (MAGMA) S:=[0]; for n in [1..104] do count:=0; for q in PrimesUpTo(n) do p:=q; s:=p; while s lt n do p:=NextPrime(p); s+:=p; end while; if s eq n then count+:=1; end if; end for; Append(~S, count); end for; S; // _Klaus Brockhaus_, Feb 17 2011

%o (Perl) use ntheory ":all"; my $n=10000; my @W=(0)x($n+1); forprimes { my $s=$_; do { $W[$s]++; $s += ($_=next_prime($_)); } while $s <= $n; } $n; print "$_ $W[$_]\n" for 0..$#W; # _Dana Jacobsen_, Aug 22 2018

%Y Cf. A000586, A054859.

%K nice,nonn

%O 0,6

%A _Jud McCranie_, May 25 2000

%E Edited by _N. J. A. Sloane_, Oct 27 2008 at the suggestion of Jake M. Foster

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.

License Agreements, Terms of Use, Privacy Policy. .

Last modified July 19 22:14 EDT 2019. Contains 325168 sequences. (Running on oeis4.)