login
A355222
The k-th leftmost digit of a(n) is the greatest of the k leftmost digits of n.
4
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 11, 12, 13, 14, 15, 16, 17, 18, 19, 22, 22, 22, 23, 24, 25, 26, 27, 28, 29, 33, 33, 33, 33, 34, 35, 36, 37, 38, 39, 44, 44, 44, 44, 44, 45, 46, 47, 48, 49, 55, 55, 55, 55, 55, 55, 56, 57, 58, 59, 66, 66, 66, 66, 66, 66, 66, 67
OFFSET
0,3
COMMENTS
Leading zeros are ignored.
LINKS
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
See A355221, A355223 and A355224 for similar sequences.
Cf. A003817 (binary analog), A009994 (fixed points).
Sequence in context: A354719 A340835 A123241 * A033862 A329201 A262038
KEYWORD
nonn,base,easy
AUTHOR
Rémy Sigrist, Jun 24 2022
STATUS
approved