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.

A350508 Numbers whose base-10 representation is a (scattered) subsequence of their base-3 representation.

Original entry on oeis.org

0, 1, 2, 10, 20, 21, 100, 102, 110, 111, 210, 211, 212, 220, 221, 222, 1000, 1010, 1011, 1020, 1021, 1022, 1110, 1111, 1112, 1121, 1122, 2000, 2001, 2010, 2011, 2012, 2021, 2022, 12101, 12102, 12111, 12112, 12120, 12121, 12122, 12201, 12202, 12221, 12222, 20220
Offset: 1

Views

Author

Jeffrey Shallit, Jan 02 2022

Keywords

Comments

Not known to be infinite.
Stan Wagon observed in an e-mail message to me (January 1 2022) that 2022 has this property, and remarked that this "will not happen again for a very long time". - Jeffrey Shallit, Jan 02 2022

Examples

			The base-3 representation of 2022 is 2202220, and 2022 is a subsequence of that.
		

Crossrefs

Cf. A038103, which deals with contiguous substrings instead of subsequences.

Programs

  • PARI
    is(n) = { if (n && vecmax(digits(n))>=3, return (0)); my (t=n); while (n && t, if (n%10==t%3, n\=10); t\=3); n==0 } \\ Rémy Sigrist, Jan 02 2022
    
  • Python
    from itertools import count, islice, product
    def ok(n): # after Remy Sigrist
        if n and int(max(str(n))) >= 3: return False
        t = n
        while n and t:
            if n%10 == t%3:
                n //= 10
            t //= 3
        return n == 0
    def agen(): # generator of terms
        yield 0
        for d in count(1):
            for first in "12":
                for rest in product("012", repeat=d-1):
                    k = int(first + "".join(rest))
                    if ok(k):
                        yield k
    print(list(islice(agen(), 46))) # Michael S. Branicky, Jan 02 2022

Extensions

a(1) = 0 prepended by Rémy Sigrist, Jan 02 2022