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.

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

A031448 Numbers whose base-2 representation has one fewer 0's than 1's.

Original entry on oeis.org

1, 5, 6, 19, 21, 22, 25, 26, 28, 71, 75, 77, 78, 83, 85, 86, 89, 90, 92, 99, 101, 102, 105, 106, 108, 113, 114, 116, 120, 271, 279, 283, 285, 286, 295, 299, 301, 302, 307, 309, 310, 313, 314, 316, 327, 331, 333, 334, 339, 341, 342
Offset: 1

Views

Author

Keywords

Comments

A037861(a(n)) = -1. - Reinhard Zumkeller, Mar 31 2015
The viabin numbers of the integer partitions in which the number of parts is equal to the largest part (for the definition of viabin number see comment in A290253). For example, 99 is in the sequence because it is the viabin number of the integer partition [4,2,2,2]. - Emeric Deutsch, Aug 29 2017

Examples

			99 is in the sequence because its binary form is 1100011. - _Emeric Deutsch_, Aug 29 2017
		

Crossrefs

Cf. A007088, A023416, A000120, A031444, subsequence of A089648.

Programs

  • Haskell
    a031448 n = a031448_list !! (n-1)
    a031448_list = filter ((== -1) . a037861) [1..]
    -- Reinhard Zumkeller, Mar 31 2015
  • Maple
    vitopart := proc (n) local L, i, j, N, p, t: N := 2*n; L := ListTools:-Reverse(convert(N, base, 2)): j := 0: for i to nops(L) do if L[i] = 0 then j := j+1: p[j] := numboccur(L[1 .. i], 1) end if end do: sort([seq(p[t], t = 1 .. j)], `>=`) end proc: A := {}; for m to 500 do if nops(vitopart(m)) = max(vitopart(m)) then A := `union`(A, {m}) else  end if end do: A; # program is based on my comment; the command vitopart(n) yields the integer partition having viabin number n. - Emeric Deutsch, Aug 29 2017
  • Mathematica
    Select[Range[400],DigitCount[#,2,1]==DigitCount[#,2,0]+1&] (* Harvey P. Dale, May 24 2019 *)

A031444 Numbers whose base-2 representation has one more 0 than 1's.

Original entry on oeis.org

4, 17, 18, 20, 24, 67, 69, 70, 73, 74, 76, 81, 82, 84, 88, 97, 98, 100, 104, 112, 263, 267, 269, 270, 275, 277, 278, 281, 282, 284, 291, 293, 294, 297, 298, 300, 305, 306, 308, 312, 323, 325, 326, 329, 330, 332, 337, 338, 340, 344
Offset: 1

Views

Author

Keywords

Comments

If m is a term, then also 4*m+1. - Reinhard Zumkeller, Mar 31 2015

Crossrefs

Cf. A007088, A023416, A000120, A031448, A037861, A095072 (subsequence).
Subsequence of A089648.

Programs

  • Haskell
    a031444 n = a031444_list !! (n-1)
    a031444_list = filter ((== 1) . a037861) [1..]
    -- Reinhard Zumkeller, Mar 31 2015
  • Mathematica
    Select[Range[350], (Differences@ DigitCount[#, 2])[[1]] == 1 &] (* Amiram Eldar, Aug 03 2023 *)

Formula

A037861(a(n)) = 1. - Reinhard Zumkeller, Mar 31 2015

A343258 Numbers whose binary representation has a prime number of zeros and a prime number of ones.

Original entry on oeis.org

9, 10, 12, 17, 18, 19, 20, 21, 22, 24, 25, 26, 28, 35, 37, 38, 41, 42, 44, 49, 50, 52, 56, 65, 66, 68, 72, 79, 80, 87, 91, 93, 94, 96, 103, 107, 109, 110, 115, 117, 118, 121, 122, 124, 131, 133, 134, 137, 138, 140, 143, 145, 146, 148, 151, 152, 155, 157, 158
Offset: 1

Views

Author

Jean-Jacques Vaudroz, Apr 09 2021

Keywords

Comments

Terms of 4, 5 and 6 total bits (9 through 56) are the same as A089648.

Crossrefs

Intersection of A052294 and A144754.
Cf. A089648.

Programs

  • Maple
    q:= n->(l->(t->andmap(isprime, [t, nops(l)-t]))(add(i, i=l)))(Bits[Split](n)):
    select(q, [$1..200])[];  # Alois P. Heinz, Apr 11 2021
  • Mathematica
    Select[Range[160], And @@ PrimeQ[DigitCount[#, 2]] &] (* Amiram Eldar, Apr 09 2021 *)
  • PARI
    isa(n)= isprime(hammingweight(n));
    isb(n)= isprime(#binary(n) - hammingweight(n));
    isok(n) = isa(n) && isb(n);
    
  • Python
    from sympy import isprime
    def ok(n): b = bin(n)[2:]; return all(isprime(b.count(d)) for d in "01")
    print(list(filter(ok, range(159)))) # Michael S. Branicky, Sep 10 2021
Showing 1-4 of 4 results.