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.

A297770 Number of distinct runs in base-2 digits of n.

This page as a plain text file.
%I A297770 #24 Aug 11 2024 10:35:28
%S A297770 1,2,1,2,2,2,1,2,2,2,3,2,3,2,1,2,2,3,3,3,2,3,3,2,3,3,2,2,3,2,1,2,2,3,
%T A297770 3,2,3,4,3,3,3,2,3,4,3,3,3,2,3,4,2,4,3,2,3,2,3,3,3,2,3,2,1,2,2,3,3,3,
%U A297770 3,4,3,3,2,3,4,3,4,4,3,3,3,3,4,3,2,3
%N A297770 Number of distinct runs in base-2 digits of n.
%C A297770 Every positive integers occurs infinitely many times.
%C A297770 ***
%C A297770 Guide to related sequences:
%C A297770 Base b      # runs    # distinct runs
%C A297770    2        A005811       A297770
%C A297770    3        A043555       A297771
%C A297770    4        A043556       A297772
%C A297770    5        A043557       A297773
%C A297770    6        A043558       A297774
%C A297770    7        A043559       A297775
%C A297770    8        A043560       A297776
%C A297770    9        A043561       A297777
%C A297770   10        A043562       A297778
%C A297770   11        A043563       A297779
%C A297770   12        A043564       A297780
%C A297770   13        A043565       A297781
%C A297770   14        A043566       A297782
%C A297770   15        A043567       A297783
%C A297770   16        A043568       A297784
%H A297770 Clark Kimberling, <a href="/A297770/b297770.txt">Table of n, a(n) for n = 1..10000</a>
%e A297770 27 in base-2: 1,1,0,1,1; three runs, of which 2 are distinct:  0 and 11, so that a(27) = 2.
%t A297770 b = 2; s[n_] := Length[Union[Split[IntegerDigits[n, b]]]]
%t A297770 Table[s[n], {n, 1, 200}]
%o A297770 (Python)
%o A297770 from itertools import groupby
%o A297770 def A297770(n): return len(set(map(lambda x:tuple(x[1]),groupby(bin(n)[2:])))) # _Chai Wah Wu_, Jul 13 2024
%o A297770 (PARI) apply( {A297770(n)=my(r=[0,0], c); while(n, my(d=bitand(n,1), L=valuation(n+d, 2)); !bittest(r[1+d], L) && c++ && r[1+d] += 1<<L; n>>=L); c}, [0..99]) \\ _M. F. Hasler_, Jul 13 2024
%o A297770 (PARI) a(n) = my(s=strjoin(binary(n)), v=vecsort(concat(strsplit(s, "1"), strsplit(s, "0")), , 8)); #v-(v[1]==""); \\ _Ruud H.G. van Tol_, Aug 05 2024
%Y A297770 Cf. A005811 (number of runs, not necessarily distinct).
%K A297770 nonn,base,easy
%O A297770 1,2
%A A297770 _Clark Kimberling_, Jan 26 2018