login
a(1) = 2; a(n) is the smallest prime greater than the sum of all previous terms.
7

%I #33 Sep 21 2021 19:31:20

%S 2,3,7,13,29,59,127,241,487,971,1949,3889,7789,15569,31139,62297,

%T 124577,249181,498331,996689,1993357,3986711,7973419,15946841,

%U 31893713,63787391,127574789,255149591,510299171,1020598339,2041196683,4082393387,8164786771,16329573527

%N a(1) = 2; a(n) is the smallest prime greater than the sum of all previous terms.

%C Grows exponentially: ceiling(log_2(a(n))) = n. - _Labos Elemer_, May 08 2002

%H Vojtech Strnad, <a href="/A070218/b070218.txt">Table of n, a(n) for n = 1..2000</a> (first 200 terms from Zak Seidov)

%p s:= proc(n) option remember; `if`(n<1, 0, s(n-1)+a(n)) end:

%p a:= proc(n) option remember; `if`(n<1, 0, nextprime(s(n-1))) end:

%p seq(a(n), n=1..35); # _Alois P. Heinz_, Sep 21 2021

%t tb[0]={} tb[x_] := Union[tb[x-1], m[x]] m[x_] := {Prime[1+PrimePi[Apply[Plus, tb[x-1]]]]} Flatten[Table[m[w], {w, 1, 10}]] (* _Labos Elemer_, May 08 2002 *)

%t bb={2};s=2;Do[p=Prime[PrimePi[s]+1];s=s+p;bb=Append[bb, p], {k, 32}];bb (Seidov)

%t Nest[Append[#,NextPrime[Total[#]]]&,{2},30] (* _Zak Seidov_, Oct 28 2011 *)

%o (PARI) print1(s=2);for(n=2,99,print1(", "t=nextprime(s+1));s+=t)

%o (Python)

%o from sympy import nextprime

%o def aupton(terms):

%o alst, s = [2], 2

%o while len(alst) < terms:

%o p = nextprime(s)

%o alst.append(p)

%o s += p

%o return alst

%o print(aupton(31)) # _Michael S. Branicky_, Sep 21 2021

%Y Cf. A063807, A151800.

%K nonn

%O 1,1

%A _Amarnath Murthy_, May 01 2002

%E More terms from _Labos Elemer_, May 08 2002

%E Corrected by _Zak Seidov_, May 21 2005