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

A037861 (Number of 0's) - (number of 1's) in the base-2 representation of n.

Original entry on oeis.org

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

Views

Author

Keywords

Comments

-Sum_{n>=1} a(n)/((2*n)*(2*n+1)) = the "alternating Euler constant" log(4/Pi) = 0.24156... - (see A094640 and Sondow 2005, 2010).
a(A072600(n)) < 0; a(A072601(n)) <= 0; a(A031443(n)) = 0; a(A072602(n)) >= 0; a(A072603(n)) > 0; a(A031444(n)) = 1; a(A031448(n)) = -1; abs(a(A089648(n))) <= 1. - Reinhard Zumkeller, Feb 07 2015

Crossrefs

Cf. A031443 for n when a(n)=0, A053738 for n when a(n) odd, A053754 for n when a(n) even, A030300 for a(n+1) mod 2.
See A268289 for a recurrence based on this sequence.

Programs

  • Haskell
    a037861 n = a023416 n - a000120 n  -- Reinhard Zumkeller, Aug 01 2013
    
  • Maple
    A037861:= proc(n) local L;
         L:= convert(n,base,2);
         numboccur(0,L) - numboccur(1,L)
    end proc:
    map(A037861, [$0..100]); # Robert Israel, Mar 08 2016
  • Mathematica
    Table[Count[ IntegerDigits[n, 2], 0] - Count[IntegerDigits[n, 2], 1], {n, 0, 75}]
  • PARI
    a(n) = if (n==0, 1, 1 + logint(n, 2) - 2*hammingweight(n)); \\ Michel Marcus, May 15 2020 and Jun 16 2020
  • Python
    def A037861(n):
        return 2*format(n,'b').count('0')-len(format(n,'b')) # Chai Wah Wu, Mar 07 2016
    

Formula

From Henry Bottomley, Oct 27 2000: (Start)
a(n) = A023416(n) - A000120(n) = A029837(n) - 2*A000120(n) = 2*A023416(n) - A029837(n).
a(2*n) = a(n) + 1; a(2*n + 1) = a(2*n) - 2 = a(n) - 1. (End)
G.f. satisfies A(x) = (1 + x)*A(x^2) - x*(2 + x)/(1 + x). - Franklin T. Adams-Watters, Dec 26 2006
a(n) = b(n) for n > 0 with b(0) = 0 and b(n) = b(floor(n/2)) + (-1)^(n mod 2). - Reinhard Zumkeller, Dec 31 2007
G.f.: 1 + (1/(1 - x))*Sum_{k>=0} x^(2^k)*(x^(2^k) - 1)/(1 + x^(2^k)). - Ilya Gutkovskiy, Apr 07 2018

A072600 Numbers which in base 2 have fewer 0's than 1's.

Original entry on oeis.org

1, 3, 5, 6, 7, 11, 13, 14, 15, 19, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 39, 43, 45, 46, 47, 51, 53, 54, 55, 57, 58, 59, 60, 61, 62, 63, 71, 75, 77, 78, 79, 83, 85, 86, 87, 89, 90, 91, 92, 93, 94, 95, 99, 101, 102, 103, 105, 106, 107, 108, 109, 110, 111, 113, 114, 115
Offset: 1

Views

Author

Reinhard Zumkeller, Jun 23 2002

Keywords

Comments

A037861(a(n)) < 0.
b_k = {a(n) | for all n s.t. a(n) contains k binary digits equal to 1} is the list of all valid win/loss round sequences in a "best of 2k-1" two player game, where 1 is a win and 0 is a loss. For example 19 = 10011b represents a game where the winner won the first two rounds, lost the next two, and won the last one. |b_k| = A001700(k). - Philippe Beaudoin, May 14 2014

Examples

			11 is present because '1011' contains 1 '0' and 3 '1's: 1<3.
		

Crossrefs

Programs

  • Haskell
    a072600 n = a072600_list !! (n-1)
    a072600_list = filter ((< 0) . a037861) [0..]
    -- Reinhard Zumkeller, Mar 31 2015
    
  • Mathematica
    Select[Range[130],DigitCount[#,2,0]Harvey P. Dale, Jan 12 2011 *)
  • PARI
    is(n)=2*hammingweight(n)>exponent(n)+1 \\ Charles R Greathouse IV, Apr 18 2020

A061854 Nondiving binary sequences: numbers which in base 2 have at least the same number of 1's as 0's and reading the binary expansion from left (msb) to right (least significant bit), the number of 0's never exceeds the number of 1's.

Original entry on oeis.org

1, 2, 3, 5, 6, 7, 10, 11, 12, 13, 14, 15, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 42, 43, 44, 45, 46, 47, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 85, 86, 87, 89, 90, 91, 92, 93, 94, 95, 101, 102, 103, 105, 106, 107, 108, 109, 110, 111, 113, 114, 115, 116
Offset: 1

Views

Author

Antti Karttunen, May 11 2001

Keywords

Comments

"msb" = "most significant bit", A053644.
These encode lattice walks using steps (+1,+1) (= 1's in binary expansion) and (+1,-1) (= 0's in binary expansion) that start from the origin (0,0) and never "dive" under the "sea-level" y=0.
The number of such walks of length n (here: the terms of binary width n) is given by C(n,floor(n/2)) = A001405, which is based on the fact mentioned in Guy's article that the shallow diagonals of the Catalan triangle A009766 sum to A001405.
From Jason Kimberley, Feb 08 2013: (Start)
This sequence is a subsequence of A072601.
Define a map from this set onto the nonnegative integers as follows: set the output bit string to be empty, representing zero; process the input string from left to right; when 1 occurs, change the rightmost 0 in the output to 1; if there is no 0 in the output, prepend a 1; when 0 occurs in the input, change the rightmost 1 in the output to 1. The definition of this sequence ensures that we always have a 1 in the output when a 0 occurs in the input. We this map is onto by showing the restriction to the subset Asubsequence is onto. (End)
The binary representation of a(n) is the numeric representation of the left half of a symmetric balanced string of parentheses with "(" representing 1 and ")" representing 0 (see comments and examples in A001405). Some of the numbers in this sequence cannot be realized as the 1-0-pattern of the odd/even positions of 1's in any row n of A237048 that determines the parts and their widths in the symmetric representation of sigma(n), see A352696. - Hartmut F. W. Hoft, Mar 29 2022

Examples

			From _Hartmut F. W. Hoft_, Mar 29 2022: (Start)
The columns in the table are the numbers n, the base-2 representation of n, the left half of the symmetric balanced string of parentheses corresponding to n, validity of the nondiving property for n, and associated number a(n):
1   1      (      True    a(1)
2   10     ()     True    a(2)
3   11     ((     True    a(3)
4   100    ())    False    -
5   101    ()(    True    a(4)
6   110    (()    True    a(5)
7   111    (((    True    a(6)
8   1000   ()))   False    -
9   1001   ())(   False    -
10  1010   ()()   True    a(7)
...
20  10100  ()())  False    -
21  10101  ()()(  True    a(13)
...
(End)
		

Crossrefs

Programs

  • Maple
    # We use a simple backtracking algorithm: map(op,[seq(NonDivingLatticeSequences(j),j=1..10)]);
    NDLS_GLOBAL := []; NonDivingLatticeSequences := proc(n) global NDLS_GLOBAL; NDLS_GLOBAL := []; NonDivingLatticeSequencesAux(0,0,n); RETURN(NDLS_GLOBAL); end;
    NonDivingLatticeSequencesAux := proc(x,h,i) global NDLS_GLOBAL; if(0 = i) then NDLS_GLOBAL := [op(NDLS_GLOBAL),x]; else if(h > 0) then NonDivingLatticeSequencesAux((2*x),h-1,i-1); fi; NonDivingLatticeSequencesAux((2*x)+1,h+1,i-1); fi; end;
  • Mathematica
    a061854[n_] := Select[Range[n], !MemberQ[FoldList[#1+If[#2>0, 1, -1]&, 0, IntegerDigits[n, 2]], -1]]
    a061854[116] (* Hartmut F. W. Hoft, Mar 29 2022 *)
    Select[Range[120],Min[Accumulate[IntegerDigits[#,2]/.(0->-1)]]>=0&] (* Harvey P. Dale, Sep 11 2023 *)

A072603 Numbers which in base 2 have more 0's than 1's.

Original entry on oeis.org

4, 8, 16, 17, 18, 20, 24, 32, 33, 34, 36, 40, 48, 64, 65, 66, 67, 68, 69, 70, 72, 73, 74, 76, 80, 81, 82, 84, 88, 96, 97, 98, 100, 104, 112, 128, 129, 130, 131, 132, 133, 134, 136, 137, 138, 140, 144, 145, 146, 148, 152, 160, 161, 162, 164, 168, 176, 192, 193
Offset: 1

Views

Author

Reinhard Zumkeller, Jun 23 2002

Keywords

Examples

			8 is present because '1000' contains 3 '0's and 1 '1': 3>1.
		

Crossrefs

Programs

  • Haskell
    a072603 n = a072603_list !! (n-1)
    a072603_list = filter ((> 0) . a037861) [1..]
    -- Reinhard Zumkeller, Mar 31 2015
    
  • Mathematica
    gtQ[n_] := Module[{a, b}, {a, b} = DigitCount[n, 2]; b > a]; Select[Range[2^8], gtQ] (* T. D. Noe, Apr 20 2013 *)
    Select[Range[200],DigitCount[#,2,0]>DigitCount[#,2,1]&] (* Harvey P. Dale, Feb 26 2023 *)
  • PARI
    is(n)=2*hammingweight(n)Charles R Greathouse IV, Apr 18 2020

A072602 Numbers such that in base 2 the number of 0's is >= the number of 1's.

Original entry on oeis.org

2, 4, 8, 9, 10, 12, 16, 17, 18, 20, 24, 32, 33, 34, 35, 36, 37, 38, 40, 41, 42, 44, 48, 49, 50, 52, 56, 64, 65, 66, 67, 68, 69, 70, 72, 73, 74, 76, 80, 81, 82, 84, 88, 96, 97, 98, 100, 104, 112, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142
Offset: 1

Views

Author

Reinhard Zumkeller, Jun 23 2002

Keywords

Examples

			8 is present because '1000' contains 3 '0's and 1 '1': 3 >= 1;
9 is present because '1001' contains 2 '0's and 2 '1's: 2 >= 2.
		

Crossrefs

Programs

  • Haskell
    a072602 n = a072602_list !! (n-1)
    a072602_list = filter ((>= 0) . a037861) [1..]
    -- Reinhard Zumkeller, Mar 31 2015
    
  • Mathematica
    Select[Range[150],DigitCount[#,2,0]>=DigitCount[#,2,1]&] (* Harvey P. Dale, May 09 2012 *)
  • PARI
    is(n)=2*hammingweight(n)<=exponent(n)+1 \\ Charles R Greathouse IV, Apr 18 2020

Extensions

Edited by N. J. A. Sloane, Jun 23 2009

A044951 Numbers having a different number of ones and zeros in base 2.

Original entry on oeis.org

1, 3, 4, 5, 6, 7, 8, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 36, 39, 40, 43, 45, 46, 47, 48, 51, 53, 54, 55, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77
Offset: 1

Views

Author

Keywords

Examples

			From _Michael De Vlieger_, Feb 07 2019: (Start)
11 (binary 1011) has more 1's than 0's, thus it is in the sequence.
12 (binary 1100) has an equal number of 0's and 1's, thus it is not in the sequence.
(End)
		

Crossrefs

Cf. A072600 (#0's < #1's), A072601 (#0's <= #1's), A031443 (#0's = #1's).
Cf. A072602 (#0's >= #1's), A072603 (#0's > #1's), this sequence (#0's <> #1's).

Programs

Formula

a(n) ~ n. - Charles R Greathouse IV, Apr 18 2020

A362030 Irregular triangle read by rows where row n contains the balanced binary words of length 2n interpreted as binary numbers.

Original entry on oeis.org

1, 2, 3, 5, 6, 9, 10, 12, 7, 11, 13, 14, 19, 21, 22, 25, 26, 28, 35, 37, 38, 41, 42, 44, 49, 50, 52, 56, 15, 23, 27, 29, 30, 39, 43, 45, 46, 51, 53, 54, 57, 58, 60, 71, 75, 77, 78, 83, 85, 86, 89, 90, 92, 99, 101, 102, 105, 106, 108, 113, 114, 116, 120, 135
Offset: 1

Views

Author

Louis Conover, Apr 05 2023

Keywords

Comments

Within a row, strings are ordered lexicographically, which means the resulting values are ordered numerically.
This is from an idea of David Lovler, which he calls "zigzags". It is a rearrangement of A072601. A072603 lists all the numbers that are not in this sequence. A000984 gives the number of coin flip sequences of length 2,4,6, etc.
Not a permutation of the integers. E.g. 8 never occurs. When there are more 0's than 1's, adding 0's doesn't bring it to balance. - Kevin Ryde, Aug 31 2023

Examples

			The first few terms written as binary words with leading 0's: 01, 10, 0011, 0101, 0110, 1001, 1010, 1100, 000111, 001011, 001101, 001110, ... (cf. A368804).
Triangle T(n,k) begins:
   1,  2;
   3,  5,  6,  9, 10, 12;
   7, 11, 13, 14, 19, 21, 22, 25, 26, 28, 35, 37, 38, ...;
  15, 23, 27, 29, 30, 39, 43, 45, 46, 51, 53, 54, 57, ...;
  ...
		

Crossrefs

Columns k=1-2 give: A000225, A083329.
Row sums give A131568.
Main diagonal gives A036563(n+1).
Cf. A000984 (row lengths), A072601, A072603, A368804 (binary).

Programs

  • Maple
    T:= n-> sort(map(Bits[Join], combinat[permute]([0$n, 1$n])))[]:
    seq(T(n), n=1..4);  # Alois P. Heinz, Apr 13 2023
  • Mathematica
    T[n_] := Sort[FromDigits[#, 2] & /@ Permutations[Join[ConstantArray[0, n], ConstantArray[1, n]]]]; Flatten[Table[T[n], {n, 1, 4}]][[1 ;; 64]] (* Robert P. P. McKone, Aug 29 2023 *)
Showing 1-7 of 7 results.