login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

The k-th leftmost digit of a(n) is the greatest of the k leftmost digits of n.
4

%I #12 Jun 26 2022 09:15:31

%S 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,

%T 26,27,28,29,33,33,33,33,34,35,36,37,38,39,44,44,44,44,44,45,46,47,48,

%U 49,55,55,55,55,55,55,56,57,58,59,66,66,66,66,66,66,66,67

%N The k-th leftmost digit of a(n) is the greatest of the k leftmost digits of n.

%C Leading zeros are ignored.

%H Rémy Sigrist, <a href="/A355222/b355222.txt">Table of n, a(n) for n = 0..10000</a>

%F a(n) >= n with equality iff n belongs to A009994.

%F a(a(n)) = a(n).

%e 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.

%o (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) }

%o (Python)

%o def a(n):

%o s, m = str(n), "0"

%o return int("".join((m:=max(m, s[k])) for k in range(len(s))))

%o print([a(n) for n in range(68)]) # _Michael S. Branicky_, Jun 24 2022

%o (Python)

%o from itertools import accumulate

%o def A355222(n): return int(''.join(accumulate(str(n),func=max))) # _Chai Wah Wu_, Jun 25 2022

%Y See A355221, A355223 and A355224 for similar sequences.

%Y Cf. A003817 (binary analog), A009994 (fixed points).

%K nonn,base,easy

%O 0,3

%A _Rémy Sigrist_, Jun 24 2022