login
A291933
a(1)=2; a(n) is the sum of prime(n) and the last digit of previous term.
1
2, 5, 10, 7, 18, 21, 18, 27, 30, 29, 40, 37, 48, 51, 48, 61, 60, 61, 68, 79, 82, 81, 84, 93, 100, 101, 104, 111, 110, 113, 130, 131, 138, 147, 156, 157, 164, 167, 174, 177, 186, 187, 198, 201, 198, 207, 218, 231, 228, 237, 240, 239, 250, 251
OFFSET
1,1
COMMENTS
All prime numbers are generated, if the last digit of a term is subtracted from the next term of the sequence.
LINKS
FORMULA
a(n) = prime(n) + a(n-1) mod 10, where a(0) = 0.
EXAMPLE
For n = 7: a(6) = 21 with last digit 1 and prime(7) = 17. 17 + 1 = 18, so a(7) = 18.
MATHEMATICA
FoldList[#2 + Mod[#1, 10] &, 0, Prime@ Range@ 54] (* Michael De Vlieger, Sep 18 2017 *)
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 *)
PROG
(PARI) {p=2; print1(p", "); forprime(n=3, 300, a=n+p%10; print1(a", "); p=a)}
CROSSREFS
Sequence in context: A188525 A324503 A126842 * A332198 A154680 A323728
KEYWORD
nonn,base
AUTHOR
Dimitris Valianatos, Sep 06 2017
EXTENSIONS
Removed vacuous a(0) in NAME. - R. J. Mathar, Jun 19 2021
STATUS
approved