login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

a(n) = a(n-1) + prime(n) - prime(n-1) + 2; a(1) = 2.
1

%I #36 Jan 19 2024 16:56:13

%S 2,5,9,13,19,23,29,33,39,47,51,59,65,69,75,83,91,95,103,109,113,121,

%T 127,135,145,151,155,161,165,171,187,193,201,205,217,221,229,237,243,

%U 251,259,263,275,279,285,289,303,317,323,327

%N a(n) = a(n-1) + prime(n) - prime(n-1) + 2; a(1) = 2.

%C The sequence shows 36 primes in the first 100 entries; the largest run of primes in these has length 4.

%H Vincenzo Librandi, <a href="/A129726/b129726.txt">Table of n, a(n) for n = 1..1000</a>

%F a(n) = a(n-1) + A001223(n-1) + 2.

%F a(n) = prime(n) + 2*n - 2. - _Bill McEachen_, Dec 02 2023

%p A129726:= proc(n) option remember;

%p if n = 1 then 2;

%p else procname(n-1)+2+ithprime(n)-ithprime(n-1);

%p end if; end proc:

%p seq(A129726(n), n=1..50) ; # _R. J. Mathar_, Feb 01 2014

%t a[n_]:= a[n]= If[n==1, 2, a[n-1] +Prime[n] -Prime[n-1] +2]; Table[a[n], {n,50}]

%t RecurrenceTable[{a[1]==2,a[n]==a[n-1]+2+Prime[n]-Prime[n-1]},a,{n,50}] (* _Harvey P. Dale_, Apr 02 2018 *)

%o (PARI) a(n) = if(n==1, 2, a(n-1) +prime(n) -prime(n-1) +2); \\ _G. C. Greubel_, Dec 02 2019

%o (Magma)

%o function a(n)

%o if n eq 1 then return 2;

%o else return a(n-1) + NthPrime(n) - NthPrime(n-1) + 2;

%o end if; return a; end function;

%o [a(n): n in [1..50]]; // _G. C. Greubel_, Dec 02 2019

%o (Sage)

%o def a(n):

%o if (n==1): return 2

%o else: return a(n-1) + nth_prime(n) - nth_prime(n-1) + 2

%o [a(n) for n in (1..50)] # _G. C. Greubel_, Dec 02 2019

%Y Cf. A000040, A001223, A005843.

%K nonn,easy

%O 1,1

%A _Roger L. Bagula_, May 12 2007