login
a(1)=2; a(n) is the sum of prime(n) and the last digit of previous term.
1

%I #38 Jun 19 2021 09:58:42

%S 2,5,10,7,18,21,18,27,30,29,40,37,48,51,48,61,60,61,68,79,82,81,84,93,

%T 100,101,104,111,110,113,130,131,138,147,156,157,164,167,174,177,186,

%U 187,198,201,198,207,218,231,228,237,240,239,250,251

%N a(1)=2; a(n) is the sum of prime(n) and the last digit of previous term.

%C All prime numbers are generated, if the last digit of a term is subtracted from the next term of the sequence.

%H Harvey P. Dale, <a href="/A291933/b291933.txt">Table of n, a(n) for n = 1..1000</a>

%F a(n) = prime(n) + a(n-1) mod 10, where a(0) = 0.

%e For n = 7: a(6) = 21 with last digit 1 and prime(7) = 17. 17 + 1 = 18, so a(7) = 18.

%t FoldList[#2 + Mod[#1, 10] &, 0, Prime@ Range@ 54] (* _Michael De Vlieger_, Sep 18 2017 *)

%t nxt[{n_,a_}]:={n+1,Prime[n+1]+Mod[a,10]}; Rest[NestList[nxt,{0,0},60][[All,2]]] (* _Harvey P. Dale_, May 26 2019 *)

%o (PARI) {p=2;print1(p", ");forprime(n=3,300,a=n+p%10;print1(a", ");p=a)}

%K nonn,base

%O 1,1

%A _Dimitris Valianatos_, Sep 06 2017

%E Removed vacuous a(0) in NAME. - _R. J. Mathar_, Jun 19 2021