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-8 of 8 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

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

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 *)

A352546 Numbers having more even than odd digits when written in base 10.

Original entry on oeis.org

0, 2, 4, 6, 8, 20, 22, 24, 26, 28, 40, 42, 44, 46, 48, 60, 62, 64, 66, 68, 80, 82, 84, 86, 88, 100, 102, 104, 106, 108, 120, 122, 124, 126, 128, 140, 142, 144, 146, 148, 160, 162, 164, 166, 168, 180, 182, 184, 186, 188, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 212
Offset: 1

Views

Author

M. F. Hasler, Jul 03 2022

Keywords

Crossrefs

Cf. A072603 (same in base 2).
Cf. A117076 (subsequence of primes).
Cf. A352547 (numbers having more odd than even decimal digits).

Programs

  • Mathematica
    A352546Q[k_] := Length[#] > 2*Count[#, _?OddQ] & [IntegerDigits[k]];
    Select[Range[0, 300], A352546Q] (* Paolo Xausa, Nov 28 2024 *)
  • PARI
    select( {is_A352546(n)=vecsum(n=digits(n)%2)*2<#n+!n}, [0..222])
    
  • Python
    def ok(n): return len(s:=str(n)) < 2*sum(1 for c in s if c in "02468")
    print([k for k in range(213) if ok(k)]) # Michael S. Branicky, Jul 03 2022

A355274 Numbers having more even than odd digits when written in base 3.

Original entry on oeis.org

0, 2, 6, 8, 9, 11, 15, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27, 29, 33, 35, 45, 47, 51, 53, 54, 55, 56, 57, 59, 60, 61, 62, 63, 65, 69, 71, 72, 73, 74, 75, 77, 78, 79, 80, 81, 82, 83, 84, 86, 87, 88, 89, 90, 92, 96, 98, 99, 100, 101, 102, 104, 105, 106, 107, 108, 110, 114, 116
Offset: 1

Views

Author

M. F. Hasler, Jul 03 2022

Keywords

Crossrefs

Cf. A072603 (same in base 2), A352546 (same in base 10).

Programs

  • PARI
    select( {is_A355274(n)=vecsum(n=digits(n,3)%2)*2<#n+!n}, [0..123])
    
  • Python
    from sympy.ntheory import digits
    def ok(n):
        d = digits(n, 3)[1:]
        return len(d) < 2*sum(1 for di in d if di%2 == 0)
    print([k for k in range(117) if ok(k)]) # Michael S. Branicky, Jul 03 2022
Showing 1-8 of 8 results.