%I #11 Jul 13 2024 22:23:08
%S 1,1,2,1,2,2,2,1,2,2,3,2,1,2,3,2,2,2,3,2,3,2,2,2,2,1,2,2,3,2,3,3,3,3,
%T 3,2,3,3,2,1,2,3,3,2,3,3,3,3,3,2,3,2,2,2,3,2,3,3,3,2,3,3,3,3,3,3,2,2,
%U 3,2,3,2,3,3,3,2,3,2,2,1,2,2,3,3,3,3,4,3,3,3,2
%N Number of distinct runs in base-3 digits of n.
%C Every positive integers occurs infinitely many times. See A297770 for a guide to related sequences.
%H Clark Kimberling, <a href="/A297771/b297771.txt">Table of n, a(n) for n = 1..10000</a>
%F a(n) << log n. In particular, a(n) <= log(n)/log(3) + 1. - _Charles R Greathouse IV_, Jul 13 2024
%e 1040 in base-3: 1,1,0,2,1,1,2; five runs, of which 3 are distinct, so that a(1040) = 3.
%t b = 3; s[n_] := Length[Union[Split[IntegerDigits[n, b]]]]
%t Table[s[n], {n, 1, 200}]
%o (Python)
%o from itertools import groupby
%o from sympy.ntheory import digits
%o def A297771(n): return len(set(map(lambda x:tuple(x[1]),groupby(digits(n,3)[1:])))) # _Chai Wah Wu_, Jul 13 2024
%o (PARI) apply( {A297771(n)=my(r=Vec(0, 3), c); while(n, my(d=n%3, L=valuation(n+if(d>1, 1, d, n+1), 3)); !bittest(r[1+d], L) && c++ && r[1+d] += 1<<L; n\=3^L); c}, [0..99]) \\ _M. F. Hasler_, Jul 13 2024
%Y Cf. A043555 (number of runs, not necessarily distinct), A297770 (this for base 2).
%K nonn,base,easy
%O 1,3
%A _Clark Kimberling_, Jan 26 2018