login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

a(n) is the smallest nonzero number that is not a substring of n in ternary representation.
5

%I #7 Feb 05 2022 16:23:32

%S 1,2,1,2,2,3,1,3,1,2,2,4,2,2,3,3,3,3,1,3,1,4,3,3,1,3,1,2,2,4,2,2,4,4,

%T 4,4,2,2,5,2,2,3,3,3,3,3,3,3,4,3,3,3,3,3,1,3,1,4,3,3,1,3,1,4,4,4,5,3,

%U 3,3,3,3,1,3,1,4,3,3,1,3,1,2,2,4,2,2

%N a(n) is the smallest nonzero number that is not a substring of n in ternary representation.

%H Reinhard Zumkeller, <a href="/A261787/b261787.txt">Table of n, a(n) for n = 0..10000</a>

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

%o (Haskell)

%o import Data.List (isInfixOf)

%o a261787 x = f $ tail a030341_tabf where

%o f (cs:css) = if isInfixOf cs (a030341_row x)

%o then f css else foldr (\d v -> 3 * v + d) 0 cs

%o (PARI) ts(n) = Str(fromdigits(digits(n, 3)));

%o a(n) = my(s=ts(n), k=1); while (#strsplit(s, ts(k)) != 1, k++); k; \\ _Michel Marcus_, Feb 05 2022

%Y Cf. A007089, A030341, A261789, A261786, A261461, A261794.

%K nonn,base

%O 0,2

%A _Reinhard Zumkeller_, Sep 01 2015