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

A039004 Numbers whose base-4 representation has the same number of 1's and 2's.

Original entry on oeis.org

0, 3, 6, 9, 12, 15, 18, 24, 27, 30, 33, 36, 39, 45, 48, 51, 54, 57, 60, 63, 66, 72, 75, 78, 90, 96, 99, 102, 105, 108, 111, 114, 120, 123, 126, 129, 132, 135, 141, 144, 147, 150, 153, 156, 159, 165, 177, 180, 183, 189, 192, 195, 198, 201, 204, 207, 210, 216, 219
Offset: 1

Views

Author

Keywords

Comments

Numbers such that sum (-1)^k*b(k) = 0 where b(k)=k-th binary digit of n (see A065359). - Benoit Cloitre, Nov 18 2003
Conjecture: a(C(2n,n)-1) = 4^n - 1. (A000984 is C(2n,n)). - Gerald McGarvey, Nov 18 2007
From Russell Jay Hendel, Jun 23 2015: (Start)
We prove the McGarvey conjecture (A) a(e(n,n)-1) = 4^n-1, with e(n,m) = A034870(n,m) = binomial(2n,m), the even rows of Pascal's triangle. By the comment from Hendel in A034870, we have the function s(n,k) = #{n-digit, base-4 numbers with n-k more 1-digits than 2-digits}. As shown in A034870, (B) #s(n,k)= e(n,k) with # indicating cardinality, that is, e(n,k) = binomial(2n,k) gives the number of n-digit, base-4 numbers with n-k more 1-digits than 2-digits.
We now show that (B) implies (A). By definition, s(n,n) contains the e(n,n) = binomial(2n,n) numbers with an equal number of 1-digits and 2-digits. The biggest n-digit, base-4 number is 333...3 (n copies of 3). Since 333...33 has zero 1-digits and zero 2-digits it follows that 333...333 is a member of s(n,n) and hence it is the biggest member of s(n,n). But 333...333 (n copies of 3) in base 4 has value 4^n-1. Since A039004 starts with index 0 (that is, 0 is the 0th member of A039004), it immediately follows that 4^n-1 is the (e(n,n)-1)st member of A039004, proving the McGarvey conjecture. (End)
Also numbers whose alternating sum of binary expansion is 0, i.e., positions of zeros in A345927. These are numbers whose binary expansion has the same number of 1's at even positions as at odd positions. - Gus Wiseman, Jul 28 2021

Crossrefs

A subset of A001969 (evil numbers).
A base-2 version is A031443 (digitally balanced numbers).
Positions of 0's in A065359 and A345927.
Positions of first appearances are A086893.
The version for standard compositions is A344619.
A000120 and A080791 count binary digits, with difference A145037.
A003714 lists numbers with no successive binary indices.
A011782 counts compositions.
A030190 gives the binary expansion of each nonnegative integer.
A070939 gives the length of an integer's binary expansion.
A097805 counts compositions by alternating (or reverse-alternating) sum.
A101211 lists run-lengths in binary expansion:
- row-lengths: A069010
- reverse: A227736
- ones only: A245563
A138364 counts compositions with alternating sum 0:
- bisection: A001700/A088218
- complement: A058622
A328594 lists numbers whose binary expansion is aperiodic.
A345197 counts compositions by length and alternating sum.

Programs

  • Fortran
    c See link in A139351.
  • Maple
    N:= 1000: # to get all terms up to N, which should be divisible by 4
    B:= Array(0..N-1):
    d:= ceil(log[4](N));
    S:= Array(0..N-1,[seq(op([0,1,-1,0]),i=1..N/4)]):
    for i from 1 to d do
      B:= B + S;
      S:= Array(0..N-1,i-> S[floor(i/4)]);
    od:
    select(t -> B[t]=0, [$0..N-1]); # Robert Israel, Jun 24 2015
  • Mathematica
    ats[y_]:=Sum[(-1)^(i-1)*y[[i]],{i,Length[y]}];
    Select[Range[0,100],ats[IntegerDigits[#,2]]==0&] (* Gus Wiseman, Jul 28 2021 *)
  • PARI
    for(n=0,219,if(sum(i=1,length(binary(n)),(-1)^i*component(binary(n),i))==0,print1(n,",")))
    

Formula

Conjecture: there is a constant c around 5 such that a(n) is asymptotic to c*n. - Benoit Cloitre, Nov 24 2002
That conjecture is false. The number of members of the sequence from 0 to 4^d-1 is binomial(2d,d) which by Stirling's formula is asymptotic to 4^d/sqrt(Pi*d). If Cloitre's conjecture were true we would have 4^d-1 asymptotic to c*4^d/sqrt(Pi*d), a contradiction. - Robert Israel, Jun 24 2015

A139351 Let the binary expansion of n be n = Sum_{k} 2^{r_k}, let e(n) be the number of r_k's that are even, o(n) the number that are odd; sequence gives e(n).

Original entry on oeis.org

0, 1, 0, 1, 1, 2, 1, 2, 0, 1, 0, 1, 1, 2, 1, 2, 1, 2, 1, 2, 2, 3, 2, 3, 1, 2, 1, 2, 2, 3, 2, 3, 0, 1, 0, 1, 1, 2, 1, 2, 0, 1, 0, 1, 1, 2, 1, 2, 1, 2, 1, 2, 2, 3, 2, 3, 1, 2, 1, 2, 2, 3, 2, 3, 1, 2, 1, 2, 2, 3, 2, 3, 1, 2, 1, 2, 2, 3, 2, 3, 2, 3, 2, 3, 3, 4, 3, 4, 2, 3, 2, 3, 3, 4, 3, 4, 1, 2, 1
Offset: 0

Views

Author

Nadia Heninger and N. J. A. Sloane, Jun 07 2008

Keywords

Comments

e(n)+o(n) = A000120(n), the binary weight of n.
a(n) is also number of 1's and 3's in 4-ary representation of n. - Frank Ruskey, May 02 2009

Examples

			For n = 43 = 2^0 + 2^1 + 2^3 + 2^5, e(43)=1, o(43)=3.
		

Crossrefs

Programs

  • Fortran
    See Sloane link.
    
  • Haskell
    import Data.List (unfoldr)
    a139351 = sum . map (`mod` 2) .
       unfoldr (\x -> if x == 0 then Nothing else Just (x, x `div` 4))
    -- Reinhard Zumkeller, Apr 22 2011
    
  • Maple
    A139351 := proc(n)
        local a,bdgs,r;
        a := 0 ;
        bdgs := convert(n,base,2) ;
        for r from 1 to nops(bdgs) by 2 do
            if op(r,bdgs) = 1 then
                a := a+1 ;
            end if;
        end do:
        a;
    end proc: # R. J. Mathar, Jul 21 2016
  • Mathematica
    terms = 99; s = (1/(1-z))*Sum[z^(4^m)/(1+z^(4^m)), {m, 0, Log[4, terms] // Ceiling}] + O[z]^terms; CoefficientList[s, z] (* Jean-François Alcover, Jul 21 2017 *)
    a[0] = 0; a[n_] := a[n] = a[Floor[n/4]] + If[OddQ[Mod[n, 4]], 1, 0]; Array[a, 100, 0] (* Amiram Eldar, Jul 18 2023 *)
  • PARI
    a(n)=if(n>3,a(n\4))+n%2 \\ Charles R Greathouse IV, Apr 21 2016

Formula

a(n) + A139352(n) = A000120(n).
G.f.: (1/(1-z))*Sum_{m>=0} (z^(4^m)/(1+z^(4^m))). - Frank Ruskey, May 03 2009
Recurrence relation: a(0)=0, a(4m) = a(4m+2) = a(m), a(4m+1) = a(4m+3) = 1+a(m). - Frank Ruskey, May 11 2009
a(n) = Sum_{k} A030308(n,k)*A059841(k). - Philippe Deléham, Oct 14 2011

Extensions

Typo in example fixed by Reinhard Zumkeller, Apr 22 2011

A139352 Let the binary expansion of n be n = Sum_{k} 2^{r_k}, let e(n) be the number of r_k's that are even, o(n) the number that are odd; sequence gives o(n).

Original entry on oeis.org

0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 2, 2, 1, 1, 2, 2, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 3, 3, 2, 2, 3, 3, 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 3, 3, 2, 2, 3, 3, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 2, 2, 1, 1, 2, 2, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2
Offset: 0

Views

Author

Nadia Heninger and N. J. A. Sloane, Jun 07 2008

Keywords

Comments

e(n) + o(n) = A000120(n), the binary weight of n.
a(n) is also the number of 2's and 3's in the 4-ary representation of n. - Frank Ruskey, May 02 2009

Examples

			For n = 43 = 2^0 + 2^1 + 2^3 + 2^5, e(43)=1, o(43)=3. [Typo fixed by _Reinhard Zumkeller_, Apr 22 2011]
		

Crossrefs

Programs

  • Fortran
    c See link in A139351
    
  • Haskell
    import Data.List (unfoldr)
    a139352 = sum . map ((`div` 2) . (`mod` 4)) .
       unfoldr (\x -> if x == 0 then Nothing else Just (x, x `div` 4))
    -- Reinhard Zumkeller, Apr 22 2011
    
  • Maple
    A139352 := proc(n)
        local a,bdgs,r;
        a := 0 ;
        bdgs := convert(n,base,2) ;
        for r from 2 to nops(bdgs) by 2 do
            if op(r,bdgs) = 1 then
                a := a+1 ;
            end if;
        end do:
        a;
    end proc: # R. J. Mathar, Jul 21 2016
  • Mathematica
    a[n_] := Count[Position[Reverse@IntegerDigits[n, 2], 1]-1, {_?OddQ}];
    Table[a[n], {n, 0, 99}] (* Jean-François Alcover, Mar 04 2023 *)
    a[0] = 0; a[n_] := a[n] = a[Floor[n/4]] + If[Mod[n, 4] > 1, 1, 0]; Array[a, 100, 0] (* Amiram Eldar, Jul 18 2023 *)
  • PARI
    a(n)=if(n>3,a(n\4))+n%4\2 \\ Charles R Greathouse IV, Apr 21 2016

Formula

G.f.: (1/(1-z))*Sum_{m>=0} (z^(2*4^m)/(1+(2*4^m))). - Frank Ruskey, May 03 2009
Recurrence relation: a(0)=0, a(4m) = a(4m+1) = a(m), a(4m+2) = a(4m+3) = 1+a(m). - Frank Ruskey, May 11 2009
a(n) = Sum_{k} A030308(n,k)*A000035(k). - Philippe Deléham, Oct 14 2011

A139370 Let the binary expansion of n be n = Sum_{k} 2^{r_k}, let e(n) be the number of r_k's that are even, o(n) the number that are odd; sequence lists n such that e(n) < o(n).

Original entry on oeis.org

2, 8, 10, 11, 14, 26, 32, 34, 35, 38, 40, 41, 42, 43, 44, 46, 47, 50, 56, 58, 59, 62, 74, 98, 104, 106, 107, 110, 122, 128, 130, 131, 134, 136, 137, 138, 139, 140, 142, 143, 146, 152, 154, 155, 158, 160, 161, 162, 163, 164, 166, 167, 168, 169, 170, 171
Offset: 1

Views

Author

Nadia Heninger and N. J. A. Sloane, Jun 07 2008

Keywords

Comments

e(n)+o(n) = A000120(n), the binary weight of n. For e(n) = o(n) see A039004.
Primes of this sequence are in A065049; but A065049 contains also other primes (see A152715). [Vladimir Shevelev, Dec 11 2008]

Crossrefs

Programs

  • Fortran
    c See link in A139351
    
  • Mathematica
    aQ[n_] := Module[{d = Reverse[IntegerDigits[n,2]]}, Total@d[[1;;-1;;2]] < Total@d[[2;;-1;;2]]]; Select[Range[180], aQ] (* Amiram Eldar, Dec 15 2018 *)
  • PARI
    isok(n) = {my(irb = Vec(select(x->(x%2), Vecrev(binary(n)), 1))); #select(x->(x%2), irb) < #irb/2;} \\ Michel Marcus, Dec 15 2018

A139354 Let the binary expansion of n be n = Sum_{k} 2^{r_k}, let e(n) be the number of r_k's that are even, o(n) the number that are odd; sequence gives min{e(n), o(n)}.

Original entry on oeis.org

0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 2, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 2, 1, 1, 2, 2, 0, 1, 0, 1, 1, 1, 1, 2, 0, 1, 0, 1, 1, 2, 1, 2, 1, 1, 1, 2, 1, 1, 2, 2, 1, 2, 1, 2, 2, 2, 2, 3, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 2, 1, 1, 2, 2, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 1
Offset: 0

Views

Author

Nadia Heninger and N. J. A. Sloane, Jun 07 2008

Keywords

Comments

e(n) + o(n) = A000120(n), the binary weight of n.

Examples

			If n = 43 = 2^0+2^2+2^3+2^5, e(43)=1, o(43)=3.
		

Crossrefs

Programs

  • Fortran
    c See link in A139351
  • Mathematica
    e[0] = 0; e[n_] := e[n] = e[Floor[n/4]] + If[OddQ[Mod[n, 4]], 1, 0];
    o[0] = 0; o[n_] := o[n] = o[Floor[n/4]] + If[Mod[n, 4] > 1, 1, 0];
    a[n_] := Min[e[n], o[n]]; Array[a, 100, 0] (* Amiram Eldar, Jul 18 2023 *)

Formula

a(n) = min(A139351(n), A139352(n)). - Amiram Eldar, Jul 18 2023

A139355 Let the binary expansion of n be n = Sum_{k} 2^{r_k}, let e(n) be the number of r_k's that are even, o(n) the number that are odd; sequence gives max{e(n), o(n)}.

Original entry on oeis.org

0, 1, 1, 1, 1, 2, 1, 2, 1, 1, 2, 2, 1, 2, 2, 2, 1, 2, 1, 2, 2, 3, 2, 3, 1, 2, 2, 2, 2, 3, 2, 3, 1, 1, 2, 2, 1, 2, 2, 2, 2, 2, 3, 3, 2, 2, 3, 3, 1, 2, 2, 2, 2, 3, 2, 3, 2, 2, 3, 3, 2, 3, 3, 3, 1, 2, 1, 2, 2, 3, 2, 3, 1, 2, 2, 2, 2, 3, 2, 3, 2, 3, 2, 3, 3, 4, 3, 4, 2, 3, 2, 3, 3, 4, 3, 4, 1, 2, 2
Offset: 0

Views

Author

Nadia Heninger and N. J. A. Sloane, Jun 07 2008

Keywords

Comments

e(n) + o(n) = A000120(n), the binary weight of n.

Examples

			If n = 43 = 2^0+2^2+2^3+2^5, e(43)=1, o(43)=3.
		

Crossrefs

Programs

  • Fortran
    c See link in A139351
  • Mathematica
    e[0] = 0; e[n_] := e[n] = e[Floor[n/4]] + If[OddQ[Mod[n, 4]], 1, 0];
    o[0] = 0; o[n_] := o[n] = o[Floor[n/4]] + If[Mod[n, 4] > 1, 1, 0];
    a[n_] := Max[e[n], o[n]]; Array[a, 100, 0] (* Amiram Eldar, Jul 18 2023 *)

Formula

a(n) = max(A139351(n), A139352(n)). - Amiram Eldar, Jul 18 2023

A139371 Let the binary expansion of n be n = Sum_{k} 2^{r_k}, let e(n) be the number of r_k's that are even, o(n) the number that are odd; sequence lists n such that e(n) <= o(n).

Original entry on oeis.org

0, 2, 3, 6, 8, 9, 10, 11, 12, 14, 15, 18, 24, 26, 27, 30, 32, 33, 34, 35, 36, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 50, 51, 54, 56, 57, 58, 59, 60, 62, 63, 66, 72, 74, 75, 78, 90, 96, 98, 99, 102, 104, 105, 106, 107, 108, 110, 111, 114, 120, 122, 123, 126
Offset: 1

Views

Author

Nadia Heninger and N. J. A. Sloane, Jun 07 2008

Keywords

Comments

e(n)+o(n) = A000120(n), the binary weight of n. For e(n) = o(n) see A039004.

Crossrefs

Programs

  • Fortran
    c See link in A139351
  • Mathematica
    q[n_] := Module[{d = Reverse[IntegerDigits[n, 2]]}, Total@ d[[1;; -1;; 2]] <= Total@ d[[2;; -1;; 2]]]; Select[Range[0, 130], q] (* Amiram Eldar, Aug 31 2023 *)

A139372 Let the binary expansion of n be n = Sum_{k} 2^{r_k}, let e(n) be the number of r_k's that are even, o(n) the number that are odd; sequence lists n such that e(n) >= o(n).

Original entry on oeis.org

0, 1, 3, 4, 5, 6, 7, 9, 12, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 27, 28, 29, 30, 31, 33, 36, 37, 39, 45, 48, 49, 51, 52, 53, 54, 55, 57, 60, 61, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91
Offset: 1

Views

Author

Nadia Heninger and N. J. A. Sloane, Jun 07 2008

Keywords

Comments

e(n)+o(n) = A000120(n), the binary weight of n. For e(n) = o(n) see A039004.

Crossrefs

Programs

  • Fortran
    c See link in A139351
  • Mathematica
    q[n_] := Module[{d = Reverse[IntegerDigits[n, 2]]}, Total@ d[[1;; -1;; 2]] >= Total@ d[[2;; -1;; 2]]]; Select[Range[0, 100], q] (* Amiram Eldar, Aug 31 2023 *)

A139373 Let the binary expansion of n be n = Sum_{k} 2^{r_k}, let e(n) be the number of r_k's that are even, o(n) the number that are odd; sequence lists n such that e(n) > o(n).

Original entry on oeis.org

1, 4, 5, 7, 13, 16, 17, 19, 20, 21, 22, 23, 25, 28, 29, 31, 37, 49, 52, 53, 55, 61, 64, 65, 67, 68, 69, 70, 71, 73, 76, 77, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 91, 92, 93, 94, 95, 97, 100, 101, 103, 109, 112, 113, 115, 116, 117, 118, 119, 121, 124
Offset: 1

Views

Author

Nadia Heninger and N. J. A. Sloane, Jun 07 2008

Keywords

Comments

e(n)+o(n) = A000120(n), the binary weight of n. For e(n) = o(n) see A039004.

Crossrefs

Programs

  • Fortran
    c See link in A139351
    
  • Mathematica
    aQ[n_] := Module[{d = Reverse[IntegerDigits[n,2]]}, Total@d[[1;;-1;;2]] > Total@d[[2;;-1;;2]]]; Select[Range[180], aQ] (* Amiram Eldar, Dec 15 2018 *)
  • PARI
    isok(n) = {my(irb = Vec(select(x->(x%2), Vecrev(binary(n)), 1))); #select(x->(x%2), irb) > #irb/2;} \\ Michel Marcus, Dec 15 2018
Showing 1-9 of 9 results.