cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Jun 24 2022

Keywords

Comments

Leading zeros are ignored.

Examples

			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.
		

Crossrefs

See A355221, A355223 and A355224 for similar sequences.
Cf. A003817 (binary analog), A009994 (fixed points).

Programs

  • 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

Formula

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