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.

Showing 1-5 of 5 results.

A038374 Length of longest contiguous block of 1's in binary expansion of n.

Original entry on oeis.org

1, 1, 2, 1, 1, 2, 3, 1, 1, 1, 2, 2, 2, 3, 4, 1, 1, 1, 2, 1, 1, 2, 3, 2, 2, 2, 2, 3, 3, 4, 5, 1, 1, 1, 2, 1, 1, 2, 3, 1, 1, 1, 2, 2, 2, 3, 4, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 5, 6, 1, 1, 1, 2, 1, 1, 2, 3, 1, 1, 1, 2, 2, 2, 3, 4, 1, 1, 1, 2, 1, 1, 2, 3, 2, 2, 2
Offset: 1

Views

Author

Keywords

Examples

			a(157) = 3 because 157 in base 2 is 10011101 and longest contiguous block of 1's is of length 3.
May be arranged into blocks of lengths 1, 2, 4, 8, 16, ...:
1,
1, 2,
1, 1, 2, 3,
1, 1, 1, 2, 2, 2, 3, 4,
1, 1, 1, 2, 1, 1, 2, 3, 2, 2, 2, 2, 3, 3, 4, 5,
1, 1, 1, 2, 1, 1, 2, 3, 1, 1, 1, 2, 2, 2, 3, 4, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 5, 6,
... - _N. J. A. Sloane_, Jul 25 2014
		

Crossrefs

Programs

  • Haskell
    import Data.List (unfoldr, group)
    a038374 = maximum . map length . filter ((== 1) . head) . group .
       unfoldr (\x -> if x == 0 then Nothing else Just $ swap $ divMod x 2)
    -- Reinhard Zumkeller, May 01 2012
    
  • Maple
    A038374 := proc(n) local nshft,thisr,resul; nshft := n ; resul :=0 ; thisr :=0 ; while nshft > 0 do if nshft mod 2 <> 0 then thisr := thisr+1 ; else resul := max(resul,thisr) ; thisr := 0 ; fi ; nshft := floor(nshft/2) ; od ; resul := max(resul,thisr) ; RETURN(resul) ; end : for n from 1 to 80 do printf("%d,",A038374(n)) ; od : # R. J. Mathar, Jun 15 2006
  • Mathematica
    Table[Max[Length/@DeleteCases[Split[IntegerDigits[n,2]],?(MemberQ[ #,0] &)]],{n,120}] (* _Harvey P. Dale, Jun 10 2013 *)
  • PARI
    a(n)=if (n==0, return (0)); n>>=valuation(n, 2); if(n<2, return(n)); my(e=valuation(n+1, 2)); max(e, a(n>>e)) \\ Charles R Greathouse IV, Jan 12 2014; edited by Michel Marcus, Apr 14 2019
    
  • Python
    from itertools import groupby
    def a(n): return max(len(list(g)) for k, g in groupby(bin(n)[1:]) if k=='1')
    print([a(n) for n in range(1, 91)]) # Michael S. Branicky, Jul 04 2022

Formula

a(n) >= A089309(n). a(n) >= A089310(n). a(2^i)=1. a(2^i-1)=i. - R. J. Mathar, Jun 15 2006
May be defined by the recurrence given in A245196, taking G(n)=n+1 (n>=0) and m=1. - N. J. A. Sloane, Jul 25 2014

A090001 Length of longest contiguous block of 1's in binary expansion of n^2.

Original entry on oeis.org

0, 1, 1, 1, 1, 2, 1, 2, 1, 1, 2, 4, 1, 1, 2, 3, 1, 1, 1, 2, 2, 3, 4, 1, 1, 3, 1, 2, 2, 2, 3, 4, 1, 1, 1, 2, 1, 2, 2, 5, 2, 2, 3, 3, 4, 6, 1, 1, 1, 2, 3, 1, 1, 5, 2, 4, 2, 2, 2, 2, 3, 3, 4, 5, 1, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 6, 2, 3, 5, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 6, 2, 1, 3, 1, 2, 1, 2, 2, 2, 3, 5
Offset: 0

Views

Author

Reinhard Zumkeller, Nov 20 2003

Keywords

Comments

a(n) = A038374(A000290(n)).

Crossrefs

Programs

  • Mathematica
    Join[{0},Table[Max[Length/@Select[Split[IntegerDigits[n^2,2]], MemberQ[ #,1]&]],{n,110}]] (* Harvey P. Dale, Nov 28 2014 *)

A090046 Length of longest contiguous block of 0's in binary expansion of n-th prime.

Original entry on oeis.org

1, 0, 1, 0, 1, 1, 3, 2, 1, 1, 0, 2, 2, 1, 1, 1, 1, 1, 4, 3, 2, 2, 2, 2, 4, 2, 2, 1, 1, 3, 0, 5, 3, 3, 2, 2, 2, 3, 2, 1, 2, 1, 1, 5, 3, 3, 2, 1, 3, 2, 2, 1, 3, 1, 7, 5, 4, 4, 3, 3, 3, 2, 2, 2, 2, 2, 2, 3, 1, 1, 4, 2, 1, 1, 1, 1, 4, 3, 3, 2, 3, 2, 1, 3, 1, 1, 5, 2, 2, 2, 2, 1, 2, 1, 2, 1, 1, 5, 5, 4, 3, 3, 3, 3, 3
Offset: 1

Views

Author

Reinhard Zumkeller, Nov 20 2003

Keywords

Crossrefs

Programs

  • Mathematica
    f[n_] := Length[ Union[ DeleteCases[ Split[ IntegerDigits[n, 2]], 1, 2]][[ -1]]]; Table[ f[ Prime[n]], {n, 1, 105}] (* Robert G. Wilson v, Dec 03 2003 *)

Formula

a(n) = A087117(A000040(n)).

A090593 Smallest prime with exactly n consecutive ones in the longest run of ones in its binary expansion.

Original entry on oeis.org

2, 3, 7, 47, 31, 191, 127, 1021, 3583, 4093, 6143, 16381, 8191, 81919, 262139, 1114111, 131071, 786431, 524287, 4194301, 14680063, 16777213, 67108859, 654311423, 671088637, 738197503, 536870909, 5368709117, 3758096383, 34359738337, 2147483647, 21474836479
Offset: 1

Views

Author

Robert G. Wilson v, Dec 03 2003

Keywords

Examples

			a(1) = 2 since 2_d = 10_b. a(2) = 3 since 3_d = 11_b. a(3) = 7 since 7_d = 111_b. a(4) = 47 since 47_d = 101111_b.
		

Crossrefs

Programs

  • Mathematica
    a = Table[0, {30}]; NextPrim[n_] := Block[{k = n + 1}, While[ ! PrimeQ[k], k++ ]; k]; p = 2; Do[ m = Length[ Union[ DeleteCases[ Split[ IntegerDigits[p, 2]], 0, 2]][[ -1]]]; If[ a[[m]] == 0, a[[m]] = p]; p = NextPrim[p], {n, 1, 117000000}]

Extensions

a(28)-a(32) from Donovan Johnson, Sep 10 2013

A307503 Least prime containing at least n consecutive 1's in its binary representation.

Original entry on oeis.org

2, 2, 3, 7, 31, 31, 127, 127, 1021, 3583, 4093, 6143, 8191, 8191, 81919, 131071, 131071, 131071, 524287, 524287, 4194301, 14680063, 16777213, 67108859, 536870909, 536870909, 536870909, 536870909, 2147483647, 2147483647, 2147483647, 2147483647, 21474836479
Offset: 0

Views

Author

John Mason, Apr 11 2019

Keywords

Comments

For n > 0, a(n) = A000040(m) for the lowest m such that A090000(m) >= n.
a(n) = A087522(n) for n = 0 through 7, and in all other cases when a(n) is a base 2 repunit (Mersenne) prime.

Examples

			a(0) = 2, the smallest prime containing >= 0 1's.
a(1) = 2, the smallest prime containing >= 1 consecutive 1's.
a(2) = 3, the smallest prime containing >= 2 consecutive 1's.
		

Crossrefs

Cf. A090593 (with exactly n consecutive ones).

Programs

  • PARI
    nbo(n)=if (n==0, return (0)); n>>=valuation(n, 2); if(n<2, return(n)); my(e=valuation(n+1, 2)); max(e, nbo(n>>e)); \\ A038374
    a(n) = my(p=2); while(nbo(p) < n, p=nextprime(p+1)); p; \\ Michel Marcus, Apr 14 2019

Formula

a(n) <= A201914(n). - Rémy Sigrist, Apr 11 2019
a(n) = min_{k>=n} A090593(k). - Chai Wah Wu, Apr 26 2019

Extensions

a(28)-a(32) from Chai Wah Wu, Apr 26 2019
Showing 1-5 of 5 results.