login
This site is supported by donations to The OEIS Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A031443 Digitally balanced numbers: numbers that in base 2 have the same number of 0's as 1's. 68
2, 9, 10, 12, 35, 37, 38, 41, 42, 44, 49, 50, 52, 56, 135, 139, 141, 142, 147, 149, 150, 153, 154, 156, 163, 165, 166, 169, 170, 172, 177, 178, 180, 184, 195, 197, 198, 201, 202, 204, 209, 210, 212, 216, 225, 226, 228, 232, 240 (list; graph; refs; listen; history; text; internal format)
OFFSET

1,1

COMMENTS

Also numbers n such that the binary digital mean dm(2, n) = sigma(i in [1, d]: d_i * 2 - 1) / (2 * d) = 0, where d is the number of digits in the binary representation of n and d_i the individual digits. - Reikku Kulon, Sep 21 2008

From Reikku Kulon, Sep 29 2008: (Start)

Each run of values begins with 2^(2k + 1) + 2^(k + 1) - 2^k - 1. The initial values increase according to the sequence {2^(k - 1), 2^(k - 2), 2^(k - 3), ..., 2^(k - k)}.

After this, the values follow a periodic sequence of increases by successive powers of two with single odd values interspersed.

Each run ends with an odd increase followed by increases of {2^(k - k), ..., 2^(k - 2), 2^(k - 1), 2^k}, finally reaching 2^(2k + 2) - 2^(k + 1).

Similar behavior occurs in other bases. (End)

Numbers n such that A000120(n)/A031443(n) = 1/2. - Ctibor O. Zizka, Oct 15 2008

Subsequence of A053754; A179888 is a subsequence. - Reinhard Zumkeller, Jul 31 2010

A000120(a(n)) = A023416(a(n)); A037861(a(n)) = 0.

A001700 gives number of terms having length 2*n in binary representation: A001700(n-1) = #{m: A070939(a(m))=2*n}. - Reinhard Zumkeller, Jun 08 2011

LINKS

Reikku Kulon, Table of n, a(n) for n = 1..10000

Jason Bell, Thomas Finn Lidbetter, Jeffrey Shallit, Additive Number Theory via Approximation by Regular Languages, arXiv:1804.07996 [cs.FL], 2018.

Reinhard Zumkeller, Haskell Programs for Binary Digitally Balanced Numbers

Index entries for sequences related to binary expansion of n

FORMULA

a(n+1) = a(n)+2^k+2^(m-1)-1+int((2^(k+m)-2^k)/a(n))*(2^(2*m)+2^(m-1)) where k is the largest integer such that 2^k divides a(n) and m is the largest integer such that 2^m divides a(n)/2^k+1. - Ulrich Schimke (UlrSchimke(AT)aol.com)

A145037(a(n)) equals zero. - Reikku Kulon, Oct 02 2008

EXAMPLE

9 is present because '1001' contains 2 '0's and 2 '1's

MAPLE

a:=proc(n) local nn, n1, n0: nn:=convert(n, base, 2): n1:=add(nn[i], i=1..nops(nn)): n0:=nops(nn)-n1: if n0=n1 then n else end if end proc: seq(a(n), n = 1..240); # Emeric Deutsch, Jul 31 2008

MATHEMATICA

Select[Range[250], DigitCount[#, 2, 1]==DigitCount[#, 2, 0]&] (* Harvey P. Dale, Jul 22 2013 *)

FromDigits[#, 2]&/@DeleteCases[Flatten[Permutations/@Table[PadRight[{}, 2n, {1, 0}], {n, 5}], 1], _?(#[[1]]==0&)]//Sort (* Harvey P. Dale, May 30 2016 *)

PROG

(PARI) for(n=1, 100, b=binary(n); l=length(b); if(sum(i=1, l, component(b, i))==l/2, print1(n, ", ")))

(PARI) is(n)=hammingweight(n)==hammingweight(bitneg(n, #binary(n))) \\ Charles R Greathouse IV, Mar 29 2013

(MAGMA) [ n: n in [2..250] | Multiplicity({* z: z in Intseq(n, 2) *}, 0) eq &+Intseq(n, 2) ];  // Bruno Berselli, Jun 07 2011

(Haskell) See link, showing that Ulrich Schimkes formula provides a very efficient algorithm. -- Reinhard Zumkeller, Jun 15 2011

(Perl) for my $half ( 1 .. 4 ) {

  my $N = 2 * $half;  # only even widths apply

  my $vector = (1 << ($N-1)) | ((1 << ($N/2-1)) - 1);  # first key

  my $n = 1; $n *= $_ for 2 .. $N;    # N!

  my $d = 1; $d *= $_ for 2 .. $N/2;  # (N/2)!

  for (1 .. $n/($d*$d*2)) {

    print "$vector, ";

    my ($v, $d) = ($vector, 0);

    until ($v & 1 or !$v) { $d = ($d << 1)|1; $v >>= 1 }

    $vector += $d + 1 + (($v ^ ($v + 1)) >> 2);  # next key

  }

} # Ruud H.G. van Tol, Mar 30 2014

CROSSREFS

Subsets: A144777, A144798, A144799, A144800, A144801, A144812.

Cf. A049354-A049360, A000120, A001316, A006519, A145057, A145058, A145059, A145060, A144912, A145037, A191292, A090050, A014486, A061854, A037861.

Terms of binary width n are enumerated by A001700.

Sequence in context: A037314 A226841 A218560 * A051017 A078180 A058890

Adjacent sequences:  A031440 A031441 A031442 * A031444 A031445 A031446

KEYWORD

nonn,base,easy,nice,changed

AUTHOR

Clark Kimberling

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent | More pages
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified October 19 22:28 EDT 2018. Contains 316378 sequences. (Running on oeis4.)