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-10 of 29 results. Next

A102370 "Sloping binary numbers": write numbers in binary under each other (right-justified), read diagonals in upward direction, convert to decimal.

Original entry on oeis.org

0, 3, 6, 5, 4, 15, 10, 9, 8, 11, 14, 13, 28, 23, 18, 17, 16, 19, 22, 21, 20, 31, 26, 25, 24, 27, 30, 61, 44, 39, 34, 33, 32, 35, 38, 37, 36, 47, 42, 41, 40, 43, 46, 45, 60, 55, 50, 49, 48, 51, 54, 53, 52, 63, 58, 57, 56, 59, 126, 93, 76, 71, 66, 65, 64, 67, 70, 69
Offset: 0

Views

Author

Philippe Deléham, Feb 13 2005

Keywords

Comments

All terms are distinct, but certain terms (see A102371) are missing. But see A103122.
Trajectory of 1 is 1, 3, 5, 15, 17, 19, 21, 31, 33, ..., see A103192.

Examples

			........0
........1
.......10
.......11
......100
......101
......110
......111
.....1000
.........
The upward-sloping diagonals are:
0
11
110
101
100
1111
1010
.......
giving 0, 3, 6, 5, 4, 15, 10, ...
The sequence has a natural decomposition into blocks (see the paper): 0; 3; 6, 5, 4; 15, 10, 9, 8, 11, 14, 13; 28, 23, 18, 17, 16, 19, 22, 21, 20, 31, 26, 25, 24, 27, 30; 61, ...
Reading the array of binary numbers along diagonals with slope 1 gives this sequence, slope 2 gives A105085, slope 0 gives A001477 and slope -1 gives A105033.
		

Crossrefs

Related sequences (1): A103542 (binary version), A102371 (complement), A103185, A103528, A103529, A103530, A103318, A034797, A103543, A103581, A103582, A103583.
Related sequences (2): A103584, A103585, A103586, A103587, A103127, A103192 (trajectory of 1), A103122, A103588, A103589, A103202 (sorted), A103205 (base 10 version).
Related sequences (3): A103747 (trajectory of 2), A103621, A103745, A103615, A103842, A103863, A104234, A104235, A103813, A105023, A105024, A105025, A105026, A105027, A105028.
Related sequences (4): A105029, A105030, A105031, A105032, A105033, A105034, A105035, A105108.

Programs

  • Haskell
    a102370 n = a102370_list !! n
    a102370_list = 0 : map (a105027 . toInteger) a062289_list
    -- Reinhard Zumkeller, Jul 21 2012
    
  • Maple
    A102370:=proc(n) local t1,l; t1:=n; for l from 1 to n do if n+l mod 2^l = 0 then t1:=t1+2^l; fi; od: t1; end;
  • Mathematica
    f[n_] := Block[{k = 1, s = 0, l = Max[2, Floor[Log[2, n + 1] + 2]]}, While[k < l, If[ Mod[n + k, 2^k] == 0, s = s + 2^k]; k++ ]; s]; Table[ f[n] + n, {n, 0, 71}] (* Robert G. Wilson v, Mar 21 2005 *)
  • PARI
    A102370(n)=n-1+sum(k=0,ceil(log(n+1)/log(2)),if((n+k)%2^k,0,2^k)) \\ Benoit Cloitre, Mar 20 2005
    
  • PARI
    {a(n) = if( n<1, 0, sum( k=0, length( binary( n)), bitand( n + k, 2^k)))} /* Michael Somos, Mar 26 2012 */
    
  • Python
    def a(n): return 0 if n<1 else sum([(n + k)&(2**k) for k in range(len(bin(n)[2:]) + 1)]) # Indranil Ghosh, May 03 2017

Formula

a(n) = n + Sum_{ k >= 1 such that n + k == 0 mod 2^k } 2^k. (Cf. A103185.) In particular, a(n) >= n. - N. J. A. Sloane, Mar 18 2005
a(n) = A105027(A062289(n)) for n > 0. - Reinhard Zumkeller, Jul 21 2012

Extensions

More terms from Benoit Cloitre, Mar 20 2005

A333766 Maximum part of the n-th composition in standard order. a(0) = 0.

Original entry on oeis.org

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

Views

Author

Gus Wiseman, Apr 05 2020

Keywords

Comments

One plus the longest run of 0's in the binary expansion of n.
A composition of n is a finite sequence of positive integers summing to n. 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. This gives a bijective correspondence between nonnegative integers and integer compositions.

Examples

			The 100th composition in standard order is (1,3,3), so a(100) = 3.
		

Crossrefs

Positions of ones are A000225.
Positions of terms <= 2 are A003754.
The version for prime indices is A061395.
Positions of terms > 1 are A062289.
Positions of first appearances are A131577.
The minimum part is given by A333768.
All of the following pertain to compositions in standard order (A066099):
- Length is A000120.
- Compositions without 1's are A022340.
- Sum is A070939.
- Product is A124758.
- 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

  • Mathematica
    stc[n_]:=Differences[Prepend[Join@@Position[Reverse[IntegerDigits[n,2]],1],0]]//Reverse;
    Table[If[n==0,0,Max@@stc[n]],{n,0,100}]

Formula

For n > 0, a(n) = A087117(n) + 1.

A038554 Derivative of n: write n in binary, replace each pair of adjacent bits with their mod 2 sum (a(0)=a(1)=0 by convention). Also n XOR (n shift 1).

Original entry on oeis.org

0, 0, 1, 0, 2, 3, 1, 0, 4, 5, 7, 6, 2, 3, 1, 0, 8, 9, 11, 10, 14, 15, 13, 12, 4, 5, 7, 6, 2, 3, 1, 0, 16, 17, 19, 18, 22, 23, 21, 20, 28, 29, 31, 30, 26, 27, 25, 24, 8, 9, 11, 10, 14, 15, 13, 12, 4, 5, 7, 6, 2, 3, 1, 0, 32, 33, 35, 34, 38, 39, 37, 36, 44, 45, 47, 46, 42, 43, 41, 40, 56, 57
Offset: 0

Views

Author

Keywords

Comments

From Antti Karttunen: this is also a version of A003188: a(n) = A003188(n) - 2^floor(log_2(A003188(n))), that is, the corresponding Gray code expansion, but with highest 1-bit turned off. Also a(n) = A003188(n) - 2^floor(log_2(n)).
From John W. Layman: {a(n)} is a self-similar sequence under Kimberling's "upper-trimming" operation.
a(A000225(n)) = 0; a(A062289(n)) > 0; a(A038558(n)) = n. - Reinhard Zumkeller, Mar 06 2013

Examples

			If n = 18 = 10010_2, derivative is (1+0)(0+0)(0+1)(1+0) = 1011_2, so a(18)=11.
		

References

  • Hsien-Kuei Hwang, S Janson, TH Tsai, Exact and asymptotic solutions of the recurrence f(n) = f(floor(n/2)) + f(ceiling(n/2)) + g(n): theory and applications, Preprint, 2016; http://140.109.74.92/hk/wp-content/files/2016/12/aat-hhrr-1.pdf. Also Exact and Asymptotic Solutions of a Divide-and-Conquer Recurrence Dividing at Half: Theory and Applications, ACM Transactions on Algorithms, 13:4 (2017), #47; DOI: 10.1145/3127585

Crossrefs

Cf. A038570, A038571. See A003415 for another definition of the derivative of a number.
Cf. A038556 (rotates n instead of shifting).
Cf. A000035.
Cf. A030308.

Programs

  • Haskell
    import Data.Bits (xor)
    a038554 n = foldr (\d v -> v * 2 + d) 0 $ zipWith xor bs $ tail bs
       where bs = a030308_row n
    -- Reinhard Zumkeller, May 26 2013, Mar 06 2013
    
  • Maple
    A038554 := proc(n) local i,b,ans; ans := 0; b := convert(n,base,2); for i to nops(b)-1 do ans := ans+((b[ i ]+b[ i+1 ]) mod 2)*2^(i-1); od; RETURN(ans); end; [ seq(A038554(i),i=0..100) ];
  • Mathematica
    a[0] = a[1] = 0; a[n_ /; Mod[n, 4] == 0] := a[n] = 2*a[n/2]; a[n_ /; Mod[n, 4] == 1] := a[n] =  2*a[(n-1)/2] + 1; a[n_ /; Mod[n, 4] == 2] := a[n] = 2*a[n/2] + 1; a[n_ /; Mod[n, 4] == 3] := a[n] = 2*a[(n-1)/2]; Table[a[n], {n, 0, 81}] (* Jean-François Alcover, Jul 13 2012, after Ralf Stephan *)
    Table[FromDigits[Mod[Total[#],2]&/@Partition[IntegerDigits[n,2],2,1],2],{n,0,90}] (* Harvey P. Dale, Oct 27 2015 *)
  • PARI
    a003188(n)=bitxor(n, n>>1);
    a(n)=if(n<2, 0, a003188(n) - 2^logint(a003188(n), 2)); \\ Indranil Ghosh, Apr 26 2017
    
  • Python
    import math
    def a003188(n): return n^(n>>1)
    def a(n): return 0 if n<2 else a003188(n) - 2**int(math.floor(math.log(a003188(n), 2))) # Indranil Ghosh, Apr 26 2017

Formula

If 2*2^k <= n < 3*2^k then a(n) = 2^k + a(2^(k+2)-n-1); if 3*2^k <= n < 4*2^k then a(n) = a(n-2^(k+1)). - Henry Bottomley, May 11 2000
G.f.: (1/(1-x)) * Sum_{k>=0} 2^k*(t^4-t^3+t^2)/(1+t^2), t=x^2^k. - Ralf Stephan, Sep 10 2003
a(0)=0, a(2n) = 2*a(n) + [n odd], a(2n+1) = 2*a(n) + [n>0 even]. - Ralf Stephan, Oct 20 2003
a(0) = a(1) = 0, a(4n) = 2*a(2n), a(4n+2) = 2*a(2n+1)+1, a(4n+1) = 2*a(2n)+1, a(4n+3) = 2*a(2n+1). Proof by Nikolaus Meyberg following a conjecture by Ralf Stephan.

Extensions

More terms from Erich Friedman

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

A261461 a(n) is the smallest nonzero number that is not a substring of n in its binary representation.

Original entry on oeis.org

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

Views

Author

Reinhard Zumkeller, Aug 30 2015

Keywords

Comments

A261018(n) = a(A260273(n)).
Is a(n) = A091460(n) for n>1? - R. J. Mathar, Sep 02 2015. The lowest counterexample occurs at a(121) = 5 < 6 = A091460(121). - Álvar Ibeas, Sep 08 2020
a(A062289(n))=A261922(A062289(n)); a(A126646(n))!=A261922(A126646(n)). - Reinhard Zumkeller, Sep 17 2015

Crossrefs

Cf. A007088, A030308, A260273, A261018; record values and where they occur: A261466, A261467.
See A261922 for a variant.

Programs

  • Haskell
    import Data.List (isInfixOf)
    a261461 x = f $ tail a030308_tabf where
       f (cs:css) = if isInfixOf cs (a030308_row x)
                       then f css else foldr (\d v -> 2 * v + d) 0 cs
    
  • Mathematica
    fQ[m_, n_] := Block[{g}, g[x_] := ToString@ FromDigits@ IntegerDigits[x, 2]; StringContainsQ[g@ n, g@ m]]; Table[k = 1; While[fQ[k, n] && k < n, k++]; k, {n, 85}] (* Michael De Vlieger, Sep 21 2015 *)
  • Python
    from itertools import count
    def a(n):
        b, k = bin(n)[2:], 1
        return next(k for k in count(1) if bin(k)[2:] not in b)
    print([a(n) for n in range(86)]) # Michael S. Branicky, Feb 26 2023

Formula

a(n) = A144016(n) + 1 for any n > 0. - Rémy Sigrist, Mar 10 2018

A101082 Numbers n such that binary representation contains bit strings "10" and "01" (possibly overlapping).

Original entry on oeis.org

5, 9, 10, 11, 13, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 29, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 61, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92
Offset: 1

Views

Author

Rick L. Shepherd, Nov 29 2004

Keywords

Comments

Subsequence of A062289; set difference A062289 minus A043569.
Complement of A023758. Also numbers not the sum of consecutive powers of 2. - Omar E. Pol, Mar 04 2013
Equivalently, numbers not the difference of two powers of two. - Charles R Greathouse IV, Mar 07 2013
The terms >=9 are bases in which a power of 2 exists, which does not contain a digit that is a power of 2. In base 10, 2^16 = 65536 is such a number, as it does not contain any one-digit power of 2, which in base 10 are 1, 2, 4 and 8. - Patrick Wienhöft, Jul 28 2016

Examples

			29 = 11101_2 is a term, "10" and "01" are contained (here overlapping).
		

Crossrefs

Complement: A023758.

Programs

  • Haskell
    a101082 n = a101082_list !! (n-1)
    a101082_list = filter ((> 0) . a049502) [0..]
    -- Reinhard Zumkeller, Jun 17 2015
    
  • Mathematica
    Select[Range@ 120, Function[d, Times @@ Total@ Map[Map[Function[k, Boole@ MatchQ[#, k]], {{1, 0}, {0, 1}}] &, Partition[d, 2, 1]] > 0]@ IntegerDigits[#, 2] &] (* Michael De Vlieger, Dec 23 2016 *)
    Select[Range[100],With[{c=IntegerDigits[#,2]},SequenceCount[c,{1,0}]>0&&SequenceCount[c,{0,1}]>0]&] (* Harvey P. Dale, Jun 08 2025 *)
  • PARI
    is(n)=n>>=valuation(n,2);n+1!=1<Charles R Greathouse IV, Mar 07 2013
    
  • Python
    def A101082(n):
        def f(x): return n+((k:=x.bit_length())*(k-1)>>1)+sum(1 for i in range(k) if (1<Chai Wah Wu, Feb 23 2025

Formula

a(n) ~ n. In particular a(n) = n + (log_2 n)^2/2 + O(log n). - Charles R Greathouse IV, Mar 07 2013
A049502(a(n)) > 0. - Reinhard Zumkeller, Jun 17 2015

A043545 (Maximal base-2 digit of n) - (minimal base-2 digit of n).

Original entry on oeis.org

0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
Offset: 0

Views

Author

Keywords

Comments

Characteristic function of A062289 (non-Mersenne numbers A000225). - Omar E. Pol, Sep 05 2021

Examples

			G.f. = x^2 + x^4 + x^5 + x^6 + x^8 + x^9 + x^10 + x^11 + x^12 + x^13 + ...
		

Crossrefs

Column k=0 of A347519.

Programs

  • Haskell
    a043545 = (1 -) . a036987  -- Reinhard Zumkeller, Nov 02 2013
  • Mathematica
    mb2d[n_]:=Module[{n2=IntegerDigits[n,2]},Max[n2]-Min[n2]]; Array[mb2d,120,0] (* Harvey P. Dale, Feb 24 2015 *)
  • PARI
    {a(n) = if( n<0, 0, n++; n != 2^valuation(n, 2))}; /* Michael Somos, Aug 25 2003 */
    
  • PARI
    a(n) = !!bitand(n, n+1); \\ Ruud H.G. van Tol, Sep 12 2023
    

Formula

0 followed by a string of 2^k - 1 1's. Also a(n)=0 iff n = 2^m - 1.
G.f.: 1/(1-x) - Sum_{k>=0} x^(2^k-1). - Michael Somos, Aug 25 2003
a(n) = 1 - A036987(n). 1's complement of Fredhold-Rueppel sequence. - Michael Somos, Aug 25 2003
a(n) = (1 + (-1)^binomial(n, floor(n/2)))/2. - Paul Barry, Jun 07 2006
Ignoring first zero and beginning instead with offset 2, a(n) = A006530(n) mod 2. - Rick L. Shepherd, Jun 09 2008
a(n) = A000777(n) mod 2, for n > 0. - John M. Campbell, Jul 16 2016

A105027 Write numbers in binary under each other; to get the next block of 2^k (k >= 0) terms of the sequence, start at 2^k, read diagonals in upward direction and convert to decimal.

Original entry on oeis.org

0, 1, 3, 2, 6, 5, 4, 7, 15, 10, 9, 8, 11, 14, 13, 12, 28, 23, 18, 17, 16, 19, 22, 21, 20, 31, 26, 25, 24, 27, 30, 29, 61, 44, 39, 34, 33, 32, 35, 38, 37, 36, 47, 42, 41, 40, 43, 46, 45, 60, 55, 50, 49, 48, 51, 54, 53, 52, 63, 58, 57, 56, 59, 62, 126, 93, 76, 71, 66, 65, 64, 67, 70
Offset: 0

Views

Author

N. J. A. Sloane, Apr 03 2005

Keywords

Comments

This is a permutation of the nonnegative integers.
Structure: blocks of size 2^k - 1 taken from A102370, interspersed with terms of A102371. - Philippe Deléham, Nov 17 2007
a(A062289(n)) = A102370(n) for n > 0; a(A000225(n)) = A102371(n); a(A214433(n)) = A105025(a(n)). - Reinhard Zumkeller, Jul 21 2012

Examples

			        0
        1
       10
       11
   -> 100  Starting here, the upward diagonals
      101  read 110, 101, 100, 111, giving the block 6, 5, 4, 7.
      110
      111
     1000
     1001
     1010
     1011
      ...
		

Crossrefs

Cf. A214414 (fixed points), A214417 (inverse).

Programs

  • Haskell
    import Data.Bits ((.|.), (.&.))
    a105027 n = foldl (.|.) 0 $ zipWith (.&.)
                      a000079_list $ enumFromTo (n + 1 - a070939 n) n
    -- Reinhard Zumkeller, Jul 21 2012
    
  • Mathematica
    block[k_] := Module[{t}, t = Table[PadLeft[IntegerDigits[n, 2], k+1], {n, 2^(k-1), 2^(k+1)-1}]; Table[FromDigits[Table[t[[n-m+1, m]], {m, 1, k+1}], 2], {n,2^(k-1)+1, 2^(k-1)+2^k}]]; block[0] = {0, 1}; Table[block[k], {k, 0, 6}] // Flatten (* Jean-François Alcover, Jun 30 2015 *)
  • PARI
    apply( {A105027(n,L=exponent(n+!n))=sum(k=0,L,bitand(n+k-L,2^k))}, [0..55]) \\ M. F. Hasler, Apr 18 2022

Formula

a(2^n - 1) = A102371(n) for n > 0. - Philippe Deléham, May 10 2005

Extensions

More terms from John W. Layman, Apr 07 2005

A043569 Numbers whose base-2 representation has exactly 2 runs.

Original entry on oeis.org

2, 4, 6, 8, 12, 14, 16, 24, 28, 30, 32, 48, 56, 60, 62, 64, 96, 112, 120, 124, 126, 128, 192, 224, 240, 248, 252, 254, 256, 384, 448, 480, 496, 504, 508, 510, 512, 768, 896, 960, 992, 1008, 1016, 1020, 1022, 1024, 1536, 1792, 1920, 1984, 2016, 2032, 2040, 2044
Offset: 1

Views

Author

Keywords

Comments

Numbers whose binary representation contains the bit string "10" but not "01". Subsequence of A062289; set difference A062289 minus A101082. - Rick L. Shepherd, Nov 29 2004
Mersenne numbers (A000225) times powers of 2 (A000079). Therefore this sequence contains the even perfect numbers (A000396). - Alonso del Arte, Apr 21 2006

Crossrefs

Programs

  • Maple
    a:=proc(n) local nn,nd: nn:=convert(n,base,2): nd:={seq(nn[j]-nn[j-1],j=2..nops(nn))}: if n=2 then 2 elif nd={0,1} then n else fi end: seq(a(n),n=1..2100); # Emeric Deutsch, Apr 21 2006
  • Mathematica
    Take[Sort[Flatten[Table[(2^x - 1)*(2^y), {x, 32}, {y, 32}]]], 54] (* Alonso del Arte, Apr 21 2006 *)
    Select[Range[2500],Length[Split[IntegerDigits[#,2]]]==2&] (* or *) Select[Range[2500],SequenceCount[IntegerDigits[#,2],{1,0}]>0 && SequenceCount[ IntegerDigits[#,2],{0,1}]==0&] (* Harvey P. Dale, Oct 04 2024 *)
  • Python
    def ok(n): b = bin(n)[2:]; return "10" in b and "01" not in b
    print([m for m in range(2045) if ok(m)]) # Michael S. Branicky, Feb 04 2021
    
  • Python
    def a_next(a_n): t = a_n >> 1; return (a_n | t) + (t & 1)
    a_n = 2; a = []
    for i in range(54): a.append(a_n); a_n = a_next(a_n) # Falk Hüffner, Feb 19 2022

Formula

This sequence is twice A023758. - Franklin T. Adams-Watters, Apr 21 2006
Sum_{n>=1} 1/a(n) = A065442. - Amiram Eldar, Feb 20 2022
A007814(a(n)) = A004736(n). - Lorenzo Sauras Altuzarra, Feb 01 2023

Extensions

More terms from Rick L. Shepherd, Nov 29 2004

A261922 a(n) = smallest nonnegative number that is not a substring of n in its binary representation.

Original entry on oeis.org

1, 0, 3, 0, 3, 3, 4, 0, 3, 3, 3, 4, 5, 4, 4, 0, 3, 3, 3, 5, 3, 3, 4, 4, 5, 5, 4, 4, 5, 4, 4, 0, 3, 3, 3, 5, 3, 3, 5, 5, 3, 3, 3, 4, 7, 4, 4, 4, 5, 5, 5, 5, 7, 4, 4, 4, 5, 5, 4, 4, 5, 4, 4, 0, 3, 3, 3, 5, 3, 3, 5, 5, 3, 3, 3, 6, 5, 7, 5, 5, 3, 3, 3, 6, 3, 3, 4, 4, 7, 7, 4, 4, 8, 4, 4, 4, 5, 5, 5, 5, 5, 7
Offset: 0

Views

Author

N. J. A. Sloane, Sep 16 2015

Keywords

Crossrefs

Programs

  • Haskell
    import Data.List (isInfixOf)
    a261922 x = f a030308_tabf where
       f (cs:css) = if isInfixOf cs (a030308_row x)
                       then f css else foldr (\d v -> 2 * v + d) 0 cs
    -- Reinhard Zumkeller, Sep 17 2015
    
  • PARI
    bstr(n) = if (n==0, "0", my(s="", b=binary(n)); for (i=1, #b, s=concat(s, b[i])); s);
    a(n) = my(sn=btostr(n), k=0); while (#strsplit(sn, bstr(k)) != 1, k++); k; \\ Michel Marcus, Sep 20 2023
    
  • Python
    def a(n): b=bin(n)[2:]; return next(k for k in range(2**len(b)) if bin(k)[2:] not in b)
    print([a(n) for n in range(99)]) # Michael S. Branicky, Sep 21 2023

Formula

From Reinhard Zumkeller, Sep 17 2015: (Start)
a(A062289(n)) = A261461(A062289(n)).
a(A126646(n)) != A261461(A126646(n)). (End)
Showing 1-10 of 29 results. Next