OFFSET
1,3
COMMENTS
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
EXAMPLE
a(1) = 1 so a(2) also = 1 since there is only one term up to and including a(1) = 1 which has digit sum >= 1. Then a(3) = 2 because now there are two terms having digit sum >= 1. a(11) = 10 so a(12) = 11 since all terms up to and including a(11) have digit sum >= 1. a(19) = 9, whose digit sum (9) sets a record, thus a(20) = 1, which means a(21) = 20.
MAPLE
R:= 1: dR:= 1:
for n from 2 to 100 do
v:= nops(select(i -> dR[i] >= dR[n-1], [$1..n-1]));
R:= R, v; dR:= dR, convert(convert(v, base, 10), `+`);
od:
R; # Robert Israel, Feb 09 2025
PROG
(PARI) first(n) = {
my(res = vector(n), digs = vector(n));
res[1] = 1; digs[1] = 1;
for(i = 2, n,
s = 1 + sum(j = 1, i-2, digs[j] >= digs[i-1]);
res[i] = s;
digs[i] = sumdigits(s)
);
res
} \\ David A. Corneth, Dec 24 2024
CROSSREFS
KEYWORD
AUTHOR
David James Sycamore, Dec 09 2024
EXTENSIONS
More terms from David A. Corneth, Dec 24 2024
STATUS
approved