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