login
Every string of 2 consecutive base-3 digits contains exactly 2 distinct numbers.
9

%I #16 Sep 15 2022 06:30:11

%S 0,1,2,3,5,6,7,10,11,15,16,19,20,21,23,30,32,33,34,46,47,48,50,57,59,

%T 60,61,64,65,69,70,91,92,96,97,100,101,102,104,138,140,141,142,145,

%U 146,150,151,172,173,177,178,181,182,183,185,192

%N Every string of 2 consecutive base-3 digits contains exactly 2 distinct numbers.

%C Essentially the same as A031941. - _R. J. Mathar_, Oct 20 2008

%H Harvey P. Dale, <a href="/A043089/b043089.txt">Table of n, a(n) for n = 0..1000</a>

%t Select[Range[0,200],FreeQ[Differences[IntegerDigits[#,3]],0]&] (* _Harvey P. Dale_, Feb 25 2022 *)

%o (PARI) a(n, base=3) = { for (b=0, oo, if (n <= (base-1)*2^b, my (v=ceil(n/2^b), p=(n-1)%(2^b)); while (b>0, v=base*v+vecsort([(v-1)%base, (v+1)%base])[1+bittest(p,b--)];); return (v), n -= (base-1)*2^b);); } \\ _Rémy Sigrist_, Sep 15 2022

%Y Cf. A031941.

%K nonn,base

%O 0,3

%A _Clark Kimberling_