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-4 of 4 results.

A087117 Number of zeros in the longest string of consecutive zeros in the binary representation of n.

Original entry on oeis.org

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

Views

Author

Reinhard Zumkeller, Aug 14 2003

Keywords

Comments

The following four statements are equivalent: a(n) = 0; n = 2^k - 1 for some k > 0; A087116(n) = 0; A023416(n) = 0.
The k-th composition in standard order (row k of A066099) is obtained by taking the set of positions of 1's in the reversed binary expansion of k, prepending 0, taking first differences, and reversing again. Then a(k) is the maximum part of this composition, minus one. The maximum part is A333766(k). - Gus Wiseman, Apr 09 2020

Crossrefs

Positions of zeros are A000225.
Positions of terms <= 1 are A003754.
Positions of terms > 0 are A062289.
Positions of first appearances are A131577.
The version for prime indices is A252735.
The proper maximum is A333766.
The version for minimum is A333767.
Maximum prime index is A061395.
All of the following pertain to compositions in standard order (A066099):
- Length is A000120.
- Sum is A070939.
- Runs are counted by A124767.
- Strict compositions are A233564.
- Constant compositions are A272919.
- Runs-resistance is A333628.
- Weakly decreasing compositions are A114994.
- Weakly increasing compositions are A225620.
- Strictly decreasing compositions are A333255.
- Strictly increasing compositions are A333256.

Programs

  • Haskell
    import Data.List (unfoldr, group)
    a087117 0       = 1
    a087117 n
      | null $ zs n = 0
      | otherwise   = maximum $ map length $ zs n where
      zs = filter ((== 0) . head) . group .
           unfoldr (\x -> if x == 0 then Nothing else Just $ swap $ divMod x 2)
    -- Reinhard Zumkeller, May 01 2012
    
  • Maple
    A087117 := proc(n)
        local d,l,zlen ;
        if n = 0 then
            return 1 ;
        end if;
        d := convert(n,base,2) ;
        for l from nops(d)-1 to 0 by -1 do
            zlen := [seq(0,i=1..l)] ;
            if verify(zlen,d,'sublist') then
                return l ;
            end if;
        end do:
        return 0 ;
    end proc; # R. J. Mathar, Nov 05 2012
  • Mathematica
    nz[n_]:=Max[Length/@Select[Split[IntegerDigits[n,2]],MemberQ[#,0]&]]; Array[nz,110,0]/.-\[Infinity]->0 (* Harvey P. Dale, Sep 05 2017 *)
  • PARI
    h(n)=if(n<2, return(0)); my(k=valuation(n,2)); if(k, max(h(n>>k), k), n++; n>>=valuation(n,2); h(n-1))
    a(n)=if(n,h(n),1) \\ Charles R Greathouse IV, Apr 06 2022

Formula

a(n) = max(A007814(n), a(A025480(n-1))) for n >= 2. - Robert Israel, Feb 19 2017
a(2n+1) = a(n) (n>=1); indeed, the binary form of 2n+1 consists of the binary form of n with an additional 1 at the end - Emeric Deutsch, Aug 18 2017
For n > 0, a(n) = A333766(n) - 1. - Gus Wiseman, Apr 09 2020

A090000 Length of longest contiguous block of 1's in binary expansion of n-th prime.

Original entry on oeis.org

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

Views

Author

Reinhard Zumkeller, Nov 20 2003

Keywords

Comments

a(n) = A038374(A000040(n)).

Crossrefs

Programs

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

A090047 Length of longest contiguous block of 0's in binary expansion of n^2.

Original entry on oeis.org

1, 0, 2, 2, 4, 2, 2, 3, 6, 3, 2, 2, 4, 2, 3, 4, 8, 4, 3, 2, 4, 2, 2, 4, 6, 3, 2, 2, 4, 2, 4, 5, 10, 5, 4, 2, 4, 2, 2, 3, 6, 3, 2, 2, 4, 2, 4, 4, 8, 4, 3, 3, 4, 2, 2, 3, 6, 3, 2, 2, 4, 3, 5, 6, 12, 6, 5, 3, 4, 2, 2, 3, 6, 3, 2, 2, 4, 2, 3, 4, 8, 4, 3, 2, 4, 4, 2, 3, 6, 3, 2, 6, 4, 4, 4, 5, 10, 5, 4, 2, 4, 2
Offset: 0

Views

Author

Reinhard Zumkeller, Nov 20 2003

Keywords

Crossrefs

Programs

  • Mathematica
    a[n_] := If[n <= 1, 1-n, Max[Length /@ Split[IntegerDigits[n^2, 2]][[2 ;; -1 ;; 2]]]]; Array[a, 100, 0] (* Amiram Eldar, Jul 28 2025 *)

Formula

a(n) = A087117(A000290(n)).

A090587 Smallest prime with exactly n consecutive zeros in the longest run of zeros in its binary expansion.

Original entry on oeis.org

3, 2, 19, 17, 67, 131, 641, 257, 2053, 10243, 4099, 12289, 40961, 32771, 65539, 65537, 262147, 786433, 4194319, 7340033, 23068673, 50331653, 67108879, 436207619, 167772161, 268435463, 268435459, 1073741831, 1073741827, 3221225473, 21474836483, 68719476767
Offset: 0

Views

Author

Robert G. Wilson v, Dec 03 2003

Keywords

Comments

Except for 2, the first and last binary digits of a prime number are 1.
One may also define a sequence of the smallest prime with its longest run of zeros containing *at least* n zeros in the binary expansion: 2, 2, 17, 17, 67, 131, 257, 257, 2053, 4099,.... - R. J. Mathar, Sep 09 2013

Examples

			a(0) = 3 since 3_d = 11_b. a(1) = 2 since 2_d = 10_b. a(3) = 17 since 17_d = 10001_b. a(6) = 641 since 641_d = 1010000001_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]], 1, 2]][[ -1]]]; If[ a[[m + 1]] == 0, a[[m + 1]] = p]; p = NextPrim[p], {n, 1, 117000000}]

Formula

min{ A000040(k): A090046(k) = n}. - R. J. Mathar, Sep 09 2013

Extensions

a(29)-a(31) from Donovan Johnson, Sep 10 2013
Showing 1-4 of 4 results.