login
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
1, 1, 2, 3, 5, 8, 15, 25, 56, 113, 293, 679, 2036, 5389, 18447, 54920, 211347, 697252, 2974827, 10741681, 50245401, 196570892, 998427899, 4197026430, 22963115248, 103007695615, 603032992418, 2870053925682, 17876478098333, 89829672327175, 592418610490868, 3129958832408526, 21764504060699104, 120464619408398977, 880014298908322768, 5086633622697900677
OFFSET
1,3
MATHEMATICA
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 *)
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 *)
PROG
(PARI) a(n) = if (n<3, 1, prime(a(n-2)) + primepi(a(n-1))); \\ Michel Marcus, Aug 30 2019
(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}
primedist(p1, p2) = {my(res = 0); forprime(p = p1 + 1, p2, res++); res} \\ David A. Corneth, Aug 30 2019
(Magma) f:= func< n | n lt 4 select Fibonacci(n) else NthPrime(Self(n-2)) + #PrimesUpTo(Self(n-1)) >;
[f(n): n in [1..25]]; // G. C. Greubel, Aug 30 2019
CROSSREFS
KEYWORD
nonn
AUTHOR
Labos Elemer, Apr 11 2003
EXTENSIONS
a(26) from David A. Corneth, Aug 30 2019
a(27)-a(30) from G. C. Greubel, Aug 30 2019
a(31)-a(36) from Chai Wah Wu, Sep 18 2019
STATUS
approved