OFFSET
0,4
LINKS
Michael De Vlieger, Table of n, a(n) for n = 0..10000
Scott R. Shannon, Image of n=0..1000000.
EXAMPLE
a(21) = 2 as a(20) = 11 which has a digit sum of 2, and there has been two previous terms with a digit sum of two: a(3) = 2 and a(20) = 11.
MATHEMATICA
nn = 94; c[_] = 0; a[0] = k = 0; c[0] = 1; Do[a[n] = c[k]; k = Total@ IntegerDigits[a[n]]; c[k]++, {n, nn}]; Array[a, nn] (* Michael De Vlieger, Oct 15 2022 *)
PROG
(Python)
from itertools import islice
from collections import Counter
def sd(n): return sum(map(int, str(n)))
def agen(): # generator of terms
an, s, inventory = 0, 0, Counter([0])
while True:
yield an; an = inventory[s]; s = sd(an); inventory[s] += 1
print(list(islice(agen(), 95))) # Michael S. Branicky, Oct 21 2022
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Scott R. Shannon, Oct 15 2022
STATUS
approved