OFFSET
1,3
LINKS
Ivan Neretin, Table of n, a(n) for n = 1..10000
EXAMPLE
a(3) = 2 because a(3-1) = 1 = 1 is not prime, hence a(3) = a(2) + 1 = 1 + 1 = 2.
a(4) = 3 because a(4-1) = 2 is prime, hence a(4) = a(3) + a(2) = 2 + 1 = 3.
a(5) = 5 because a(5-1) = 3 is prime, hence a(5) = a(4) + a(3) = 3 + 2 = 5.
a(6) = 8 because a(6-1) = 5 is prime, hence a(6) = a(5) + a(4) = 5 + 3 = 8.
a(7) = 9 because a(7-1) = 8 is not prime, hence a(7) = a(6) + 1 = 8 + 1 = 9.
a(8) = 10 because a(8-1) = 9 is not prime, hence a(8) = a(7) + 1 = 9 + 1 = 10.
MATHEMATICA
a[1] = a[2] = 1; a[n_] := a[n] = If[ PrimeQ[ a[n - 1]], a[n - 1] + a[n - 2], a[n - 1] + 1]; Table[ a[n], {n, 53}] (* Robert G. Wilson v, Oct 14 2005 *)
nxt[{a_, b_}]:={b, If[PrimeQ[b], a+b, b+1]}; NestList[nxt, {1, 1}, 60][[All, 1]] (* Harvey P. Dale, Dec 23 2020 *)
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Jonathan Vos Post, Oct 12 2005
STATUS
approved