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

%I #14 Jun 26 2022 09:15:39

%S 0,1,2,3,4,5,6,7,8,9,10,11,22,33,44,55,66,77,88,99,20,21,22,33,44,55,

%T 66,77,88,99,30,31,32,33,44,55,66,77,88,99,40,41,42,43,44,55,66,77,88,

%U 99,50,51,52,53,54,55,66,77,88,99,60,61,62,63,64,65,66,77

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

%C Leading zeros are ignored.

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

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

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

%e For n = 1402:

%e - max({1, 4, 0, 2}) = 4,

%e - max({4, 0, 2}) = 4,

%e - max({0, 2}) = 2,

%e - max({2}) = 2,

%e - so a(1402) = 4422.

%o (PARI) a(n, base=10) = { my (d=digits(n, base), m=-oo); forstep (k=#d, 1, -1, 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[-1-k])) for k in range(len(s)))[::-1])

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

%o (Python)

%o from itertools import accumulate

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

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

%Y Cf. A009996 (fixed points), A340632 (binary analog).

%K nonn,base,easy

%O 0,3

%A _Rémy Sigrist_, Jun 24 2022