OFFSET
0,3
COMMENTS
Leading zeros are ignored.
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..10000
FORMULA
a(n) >= n with equality iff n belongs to A009994.
a(a(n)) = a(n).
EXAMPLE
For n = 1402: max({1}) = 1, max({1, 4}) = 4, max({1, 4, 0}) = 4, max({1, 4, 0, 2}) = 4, so a(1402) = 1444.
PROG
(PARI) a(n, base=10) = { my (d=digits(n, base), m=-oo); for (k=1, #d, d[k]=m=max(m, d[k])); fromdigits(d, base) }
(Python)
def a(n):
s, m = str(n), "0"
return int("".join((m:=max(m, s[k])) for k in range(len(s))))
print([a(n) for n in range(68)]) # Michael S. Branicky, Jun 24 2022
(Python)
from itertools import accumulate
def A355222(n): return int(''.join(accumulate(str(n), func=max))) # Chai Wah Wu, Jun 25 2022
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Rémy Sigrist, Jun 24 2022
STATUS
approved