A364788 a(0) = 0; thereafter a(n) is the number of times the last digit of a(n-1) has occurred as last digit in all terms prior to a(n-1).
0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 11, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 12, 2, 3, 2, 4, 2, 5, 2, 6, 2, 7, 2, 8, 2, 9, 2, 10, 13, 3, 4, 3, 5, 3, 6, 3, 7, 3, 8, 3, 9, 3, 10, 14, 4, 5, 4, 6, 4, 7, 4, 8, 4, 9, 4, 10
Offset: 0
Examples
a(1) = 0 because a(0) = 0 has been repeated 0 times. a(2) = 1 because a(1) = 0 has been repeated once. a(22) = 11 has last digit 1, and there has been only one occurrence of a prior term having 1 as last digit (a(2) = 1), therefore a(23) = 1. a(53) = 2 (last digit is 2) and there are 9 prior terms with last digit = 2 (8 terms = 2, and a(40) = 12). Therefore a(54) = 9.
Links
- Michael De Vlieger, Table of n, a(n) for n = 0..10000
- Michael De Vlieger, Scatterplot of a(n), n = 0..1024, with a color function showing r = a(n-1) mod 10 in black if r = 0, red if r = 1, ..., magenta if r = 9.
Crossrefs
Cf. A248034.
Programs
-
Mathematica
nn = 120; a[0] = j = 0; c[] := 0; Do[(a[n] = c[#]; c[#]++) &[Mod[j, 10]]; j = a[n], {n, nn}]; Array[a, nn, 0] (* _Michael De Vlieger, Aug 08 2023 *)
-
Python
from collections import Counter from itertools import count, islice def agen(): # generator of terms an, c = 0, Counter() while True: yield an key = an%10 an = c[key] c[key] += 1 print(list(islice(agen(), 85))) # Michael S. Branicky, Mar 24 2025
Extensions
More terms from Michael De Vlieger, Aug 08 2023
Comments