login
A356348
a(0) = 0; for n > 0, a(n) is the number of preceding terms having the same digit sum as a(n-1).
6
0, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 11, 2, 3, 2, 4, 2, 5, 2, 6, 2, 7, 2, 8, 2, 9, 2, 10, 12, 3, 4, 3, 5, 3, 6, 3, 7, 3, 8, 3, 9, 3, 10, 13, 4, 5, 4, 6, 4, 7, 4, 8, 4, 9, 4, 10, 14, 5, 6, 5, 7, 5, 8, 5, 9, 5, 10, 15, 6, 7, 6, 8, 6, 9, 6, 10, 16, 7, 8, 7, 9, 7, 10, 17, 8, 9
OFFSET
0,4
LINKS
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
Cf. A007953, A137671 (base 2), A342585.
Sequence in context: A248034 A358967 A322182 * A336514 A358851 A249009
KEYWORD
nonn,base
AUTHOR
Scott R. Shannon, Oct 15 2022
STATUS
approved