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

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

A072601 Numbers which in base 2 have at least as many 1's as 0's.

Original entry on oeis.org

1, 2, 3, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 19, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 35, 37, 38, 39, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53, 54, 55, 56, 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
Offset: 1

Views

Author

Reinhard Zumkeller, Jun 23 2002

Keywords

Examples

			8 = 1000_2 is not present (one '1', three '0's).
10 is present because 10=1010_2 contains 2 '0's and 2 '1's: 2<=2;
11 is present because 11=1011_2 contains 1 '0' and 3 '1's: 1<=3.
		

Crossrefs

Cf. A037861(a(n)) <= 0.
Cf. A072600 (#0's < #1's), this seq (#0's <= #1's), A031443 (#0's = #1's).
Cf. A072602 (#0's >= #1's), A072603 (#0's > #1's), A044951 (#0's <> #1's).

Programs

  • Haskell
    a072601 n = a072601_list !! (n-1)
    a072601_list = filter ((<= 0) . a037861) [0..]
    -- Reinhard Zumkeller, Aug 01 2013
    
  • Mathematica
    geQ[n_] := Module[{a, b}, {a, b} = DigitCount[n, 2]; a >= b]; Select[Range[103], geQ] (* T. D. Noe, Apr 20 2013 *)
    Select[Range[110],DigitCount[#,2,1]>=DigitCount[#,2,0]&] (* Harvey P. Dale, Aug 12 2023 *)
  • PARI
    is(n)=2*hammingweight(n)>exponent(n) \\ Charles R Greathouse IV, Apr 18 2020

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

A374664 Nonnegative numbers whose binary expansion has no ones in common with some of its cyclic shifts.

Original entry on oeis.org

0, 2, 4, 8, 9, 10, 12, 16, 17, 18, 20, 24, 32, 33, 34, 35, 36, 40, 42, 48, 49, 56, 64, 65, 66, 67, 68, 72, 73, 74, 76, 80, 82, 84, 96, 97, 100, 112, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 140, 144, 145, 146, 148, 150, 152, 153, 160, 161, 162
Offset: 1

Views

Author

Rémy Sigrist, Jul 15 2024

Keywords

Comments

Leading zeros in binary expansions are ignored.
All positive terms belong to A072602.
A number k belongs to the sequence iff A001196(k) belongs to the sequence.

Examples

			The first terms, with their binary expansion and an appropriate cyclic shift, are:
  n   a(n)  bin(a(n))  cyc
  --  ----  ---------  ------
   1     0          0       0
   2     2         10      01
   3     4        100     001
   4     8       1000    0001
   5     9       1001    0110
   6    10       1010    0101
   7    12       1100    0011
   8    16      10000   00001
   9    17      10001   00110
  10    18      10010   00101
  11    20      10100   01001
  12    24      11000   00011
  13    32     100000  000001
  14    33     100001  000110
  15    34     100010  000101
  16    35     100011  011100
		

Crossrefs

Programs

  • PARI
    is(n) = { my (x = max(exponent(n), 0), s = n); for (i = 0, x, s = (s >> 1) + if (s%2, 2^x, 0); if (bitand(s, n)==0, return (1););); return (0); }

A093327 Smallest sequence of numbers having in their binary representation alternately more (>) or not-more (<=) binary ones than zeros.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 8, 11, 12, 13, 16, 19, 20, 21, 24, 25, 32, 39, 40, 43, 44, 45, 48, 51, 52, 53, 56, 57, 64, 71, 72, 75, 76, 77, 80, 83, 84, 85, 88, 89, 96, 99, 100, 101, 104, 105, 112, 113, 128, 143, 144, 151, 152, 155, 156, 157, 160, 167, 168, 171, 172, 173, 176
Offset: 0

Views

Author

Reinhard Zumkeller, Jul 12 2004

Keywords

Comments

A000120(a(n)) < A023416(a(n)) iff A000120(a(n+1))>=A023416(a(n+1));
A037861(a(2*n)) >= 0, A037861(a(2*n+1)) < 0.

Crossrefs

Showing 1-7 of 7 results.