|
|
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
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,4
|
|
LINKS
|
|
|
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
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|