A350508 Numbers whose base-10 representation is a (scattered) subsequence of their base-3 representation.
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
Examples
The base-3 representation of 2022 is 2202220, and 2022 is a subsequence of that.
Links
- Rémy Sigrist, Table of n, a(n) for n = 1..10000
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
Comments