OFFSET
0,4
COMMENTS
Inspired by A248034.
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..10000
Alois P. Heinz, Graph of 10^6 terms
MAPLE
a:= proc(n) option remember; `if`(n=0, 0,
coeff(b(n-1), x, convert(a(n-1), base, 10)[-1] ))
end:
b:= proc(n) option remember; `if`(n=0, 1, b(n-1)+
add(x^i, i=convert(a(n), base, 10)))
end:
seq(a(n), n=0..120);
PROG
(MIT/GNU Scheme with memoizing definec-macro from Antti Karttunen's IntSeq-library)
(definec (A249009 n) (if (zero? n) n (vector-ref (A249009aux_digit_counts (- n 1)) (A000030 (A249009 (- n 1))))))
(definec (A249009aux_digit_counts n) (cond ((zero? n) (vector 1 0 0 0 0 0 0 0 0 0)) (else (let loop ((digcounts-for-n (vector-copy (A249009aux_digit_counts (- n 1)))) (n (A249009 n))) (cond ((zero? n) digcounts-for-n) (else (vector-set! digcounts-for-n (modulo n 10) (+ 1 (vector-ref digcounts-for-n (modulo n 10)))) (loop digcounts-for-n (floor->exact (/ n 10)))))))))
(define (A000030 n) (let loop ((n n)) (if (< n 10) n (loop (floor->exact (/ n 10))))))
;; Antti Karttunen, Oct 20 2014
(Python)
from itertools import islice
def A249009_gen(): # generator of terms
c, clist = 0, [1]+[0]*9
while True:
yield c
c = clist[int(str(c)[0])]
for d in str(c):
clist[int(d)] += 1
CROSSREFS
KEYWORD
AUTHOR
Alois P. Heinz, Oct 18 2014
STATUS
approved