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.

A043276 a(n) = maximal run length in base-2 representation of n.

This page as a plain text file.
%I A043276 #31 Mar 10 2023 02:32:12
%S A043276 1,1,2,2,1,2,3,3,2,1,2,2,2,3,4,4,3,2,2,2,1,2,3,3,2,2,2,3,3,4,5,5,4,3,
%T A043276 3,2,2,2,3,3,2,1,2,2,2,3,4,4,3,2,2,2,2,2,3,3,3,3,3,4,4,5,6,6,5,4,4,3,
%U A043276 3,3,3,3,2,2,2,2,2,3,4,4,3,2,2,2,1,2,3,3,2,2,2,3,3,4,5,5,4,3,3,2,2,2,3,3,2
%N A043276 a(n) = maximal run length in base-2 representation of n.
%C A043276 First occurrence of k is when n=2^k-1 and there is no last occurrence. - _Robert G. Wilson v_, Dec 14 2008
%C A043276 Sequences A000975, A037969, A037970, A037971 list numbers for which a(n)=1, a(n)=2, a(n)=3, a(n)=4. - _M. F. Hasler_, Jul 23 2013
%C A043276 a(n) = max(A101211(n,k): k = 1..A005811(n)). - _Reinhard Zumkeller_, Dec 16 2013
%H A043276 Reinhard Zumkeller, <a href="/A043276/b043276.txt">Table of n, a(n) for n = 1..10000</a>
%p A043276 A043276 := proc(n)
%p A043276     local a,rl,i ;
%p A043276     if n > 0 then
%p A043276         rl := 1 ;
%p A043276     else
%p A043276         rl := 0 ;
%p A043276     end if;
%p A043276     a := rl ;
%p A043276     dgs := convert(n,base,2) ;
%p A043276     for i from 2 to nops(dgs) do
%p A043276         if op(i,dgs) = op(i-1,dgs) then
%p A043276             rl := rl+1 ;
%p A043276             a := max(a,rl) ;
%p A043276         else
%p A043276             a := max(a,rl) ;
%p A043276             rl := 1;
%p A043276         end if;
%p A043276     end do:
%p A043276     a ;
%p A043276 end proc:
%p A043276 seq(A043276(n),n=1...80) ; # _R. J. Mathar_, Jun 04 2021
%t A043276 f[n_] := Max @@ Length /@ Split@IntegerDigits[n, 2]; Array[f, 105] (* _Robert G. Wilson v_, Dec 14 2008 *)
%o A043276 (PARI) A043276(n,b=2)={my(m,c=1);while(n>0,n%b==(n\=b)%b && c++ && next;m=max(m,c);c=1);m} \\ _M. F. Hasler_, Jul 23 2013
%o A043276 (PARI) a(n)=my(r,t); while(n, t=valuation(n,2); if(t>r, r=t); n>>=t; t=valuation(n+1,2); if(t>r, r=t); n>>=t); r \\ _Charles R Greathouse IV_, Nov 02 2016
%o A043276 (Haskell)
%o A043276 a043276 = maximum . a101211_row  -- _Reinhard Zumkeller_, Dec 16 2013
%o A043276 (Python)
%o A043276 from itertools import groupby
%o A043276 def A043276(n): return max(len(list(g)) for k, g in groupby(bin(n)[2:])) # _Chai Wah Wu_, Mar 09 2023
%Y A043276 Cf. A043277-A043290 for base-3 to base-16 analogs.
%K A043276 nonn,base,look
%O A043276 1,3
%A A043276 _Clark Kimberling_
%E A043276 More terms from _Robert G. Wilson v_, Dec 14 2008