login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A082095 A 2nd order recursion: a(1)=a(2)=1, a(n) = prime(a(n-2)) + pi(a(n-1)) = A000040(a(n-2)) + A000720(a(n-1)). 3

%I #33 Sep 08 2022 08:45:09

%S 1,1,2,3,5,8,15,25,56,113,293,679,2036,5389,18447,54920,211347,697252,

%T 2974827,10741681,50245401,196570892,998427899,4197026430,22963115248,

%U 103007695615,603032992418,2870053925682,17876478098333,89829672327175,592418610490868,3129958832408526,21764504060699104,120464619408398977,880014298908322768,5086633622697900677

%N A 2nd order recursion: a(1)=a(2)=1, a(n) = prime(a(n-2)) + pi(a(n-1)) = A000040(a(n-2)) + A000720(a(n-1)).

%t a[n_]:= a[n]= If[n<4, Fibonacci[n], Prime[a[n-2]] +PrimePi[a[n-1]]]; Table[a[n], {n, 30}] (* modified by _G. C. Greubel_, Aug 30 2019 *)

%t nxt[{a_,b_}]:={b,Prime[a]+PrimePi[b]}; NestList[nxt,{1,1},30][[All,1]] (* The program generates the first 31 terms of the sequence. *) (* _Harvey P. Dale_, May 16 2020 *)

%o (PARI) a(n) = if (n<3, 1, prime(a(n-2)) + primepi(a(n-1))); \\ _Michel Marcus_, Aug 30 2019

%o (PARI) first(n) = {my(res = vector(max(3, n)), pr = vector(n)); res[1] = res[2] = 1; res[3] = 2; for(i = 1, 3, print1(res[i]", ")); pr[1] = pr[2] = 2; pr[3] = 3; for(i = 4, n, pr[i] = prime(res[i-2]); res[i] = pr[i] + res[i-3] + primedist(pr[i-1], res[i-1]); print1(res[i]", ")); res}

%o primedist(p1, p2) = {my(res = 0); forprime(p = p1 + 1, p2, res++); res} \\ _David A. Corneth_, Aug 30 2019

%o (Magma) f:= func< n | n lt 4 select Fibonacci(n) else NthPrime(Self(n-2)) + #PrimesUpTo(Self(n-1)) >;

%o [f(n): n in [1..25]]; // _G. C. Greubel_, Aug 30 2019

%Y Cf. A000040, A000720, A069103, A082094.

%K nonn

%O 1,3

%A _Labos Elemer_, Apr 11 2003

%E a(26) from _David A. Corneth_, Aug 30 2019

%E a(27)-a(30) from _G. C. Greubel_, Aug 30 2019

%E a(31)-a(36) from _Chai Wah Wu_, Sep 18 2019

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 23 10:29 EDT 2024. Contains 371905 sequences. (Running on oeis4.)