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.

A031443 Digitally balanced numbers: positive numbers that in base 2 have the same number of 0's as 1's.

Original entry on oeis.org

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, 527, 535, 539, 541, 542, 551
Offset: 1

Views

Author

Keywords

Comments

Also numbers k such that the binary digital mean dm(2, k) = (Sum_{i=1..d} 2*d_i - 1) / (2*d) = 0, where d is the number of digits in the binary representation of k 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 k such that A000120(k)/A070939(k) = 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
The number of terms below 2^k is A079309(floor(k/2)) for k > 1. - Amiram Eldar, Nov 21 2020

Examples

			9 is a term because '1001' contains 2 '0's and 2 '1's.
		

Crossrefs

Subsequence of A053754.
Row n = 2 of A378000.
Terms of binary width n are enumerated by A001700.

Programs

  • Haskell
    -- See link, showing that Ulrich Schimkes formula provides a very efficient algorithm. Reinhard Zumkeller, Jun 15 2011
    
  • Magma
    [ n: n in [2..250] | Multiplicity({* z: z in Intseq(n,2) *}, 0) eq &+Intseq(n,2) ];  // Bruno Berselli, Jun 07 2011
    
  • 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 *)
  • 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
    
  • PARI
    is(n)=2*hammingweight(n)==exponent(n)+1 \\ Charles R Greathouse IV, Apr 18 2020
    
  • 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
    
  • Python
    from sympy.utilities.iterables import multiset_permutations
    A031443_list = [int('1'+''.join(p),2) for n in range(1,10) for p in multiset_permutations('0'*n+'1'*(n-1))] # Chai Wah Wu, Nov 15 2019

Formula

a(n+1) = a(n) + 2^k + 2^(m-1) - 1 + floor((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)) = 0. - Reikku Kulon, Oct 02 2008

A337238 Number k such that k and k+1 are both digitally balanced numbers in base 2 (A031443).

Original entry on oeis.org

9, 37, 41, 49, 141, 149, 153, 165, 169, 177, 197, 201, 209, 225, 541, 557, 565, 569, 589, 597, 601, 613, 617, 625, 653, 661, 665, 677, 681, 689, 709, 713, 721, 737, 781, 789, 793, 805, 809, 817, 837, 841, 849, 865, 901, 905, 913, 929, 961, 2109, 2141, 2157, 2165
Offset: 1

Views

Author

Amiram Eldar, Nov 21 2020

Keywords

Comments

All the terms are of the form 4*k + 1, where k is a digitally balanced number in base 2. Therefore, there are no 3 consecutive numbers that are digitally balanced in base 2.
The number of terms below 2^k is A079309(floor(k/2)-1) for k > 3.

Examples

			9 is a term since the binary representation of 9 is 1001, which contains 2 0's and 2 1's, and the binary representation of 9 + 1 = 10 is 1010, which also contains 2 0's and 2 1's.
		

Crossrefs

A206374 \ {2} is a subsequence.

Programs

  • Mathematica
    digBalQ[n_] := Module[{d = IntegerDigits[n, 2], m}, EvenQ@(m = Length@d) && Count[d, 1] == m/2]; Select[Range[2000], digBalQ[#] && digBalQ[# + 1] &]

Formula

a(n) = 4*A031443(n) + 1.

A191341 a(n) = 4^n - 2*2^n + 3.

Original entry on oeis.org

3, 11, 51, 227, 963, 3971, 16131, 65027, 261123, 1046531, 4190211, 16769027, 67092483, 268402691, 1073676291, 4294836227, 17179607043, 68718952451, 274876858371, 1099509530627, 4398042316803, 17592177655811, 70368727400451, 281474943156227, 1125899839733763
Offset: 1

Views

Author

Juri-Stepan Gerasimov, May 30 2011

Keywords

Comments

Also the number of dominating sets for the complete bipartite graph K_{n,n}. - Eric W. Weisstein, Apr 24 2017
For n > 1, a(n) is the largest integer such that the binary representations of a(n)-1 and a(n)+1 both contain exactly n 0's and n 1's.

Crossrefs

Cf. A031443 (digitally balanced numbers), A191292, A191296.

Programs

  • GAP
    List([1..30], n -> (2^n-1)^2+2); # G. C. Greubel, Feb 10 2019
  • Magma
    [4^n - 2^(n+1) + 3: n in [1..30]]; // Vincenzo Librandi, Jun 09 2011
    
  • Mathematica
    Table[3 - 2^(1+n) + 4^n, {n, 20}] (* Eric W. Weisstein, Apr 24 2017 *)
    With[{r = Range[10^5]}, 2 + SplitBy[Cases[Transpose[{Partition[Tally[#][[All, 2]] & /@ IntegerDigits[r, 2], 2, 1, 1], r}], {{{n_, n_}, {n_, n_}}, p_} :> {n, p}], First][[All, -1, -1]]] (* Eric W. Weisstein, Apr 24 2017 *)
    LinearRecurrence[{7, -14, 8}, {3, 11, 51}, 20] (* Eric W. Weisstein, Jun 29 2017 *)
    CoefficientList[Series[(3-10x+16x^2)/((1-x)(1-2x)(1-4x)), {x, 0, 20}], x] (* Eric W. Weisstein, Jun 29 2017 *)
  • PARI
    a(n)=4^n-2*2^n+3 \\ Charles R Greathouse IV, Jun 08 2011
    
  • Sage
    [(2^n-1)^2+2 for n in (1..30)] # G. C. Greubel, Feb 10 2019
    

Formula

a(n) = 4^n - 2^(n+1) + 3. - Nathaniel Johnston, May 30 2011
a(n) = 7*a(n-1) - 14*a(n-2) + 8*a(n-3). - Eric W. Weisstein, Jun 29 2017
G.f.: (3 -10*x +16*x^2)/((1-x)*(1-2*x)*(1-4*x)). - R. J. Mathar, Jun 02 2011 ( corrected by G. C. Greubel, Feb 10 2019 )
E.g.f.: -2 + 3*exp(x) - 2*exp(2*x) + exp(4*x). - G. C. Greubel, Feb 10 2019

Extensions

Definition changed to closed-form formula and original definition clarified and moved to comment by Eric W. Weisstein, Apr 24 2017

A191296 Least k such that k-1 and k+1 in binary representation have same number n of 0's as 1's.

Original entry on oeis.org

11, 36, 140, 540, 2108, 8316, 33020, 131580, 525308, 2099196, 8392700, 33562620, 134234108, 536903676, 2147549180, 8590065660, 34360000508, 137439477756, 549756862460, 2199025352700, 8796097216508, 35184380477436, 140737505132540, 562949986975740, 2251799880794108, 9007199388958716, 36028797287399420
Offset: 2

Views

Author

Juri-Stepan Gerasimov, May 29 2011

Keywords

Crossrefs

Cf. A031443 (digitally balanced numbers), A191292, A191341.

Programs

  • Mathematica
    Join[{11},LinearRecurrence[{7,-14,8},{36,140,540},40]] (* Harvey P. Dale, Jun 10 2011 *)
  • PARI
    a(n)=if(n<3,11,2*(2^(n-1) + 2)*(2^(n-1) - 1)) \\ Charles R Greathouse IV, Jun 01 2011
    
  • PARI
    Vec(x^2*(11 - 41*x + 42*x^2 - 24*x^3) / ((1 - x)*(1 - 2*x)*(1 - 4*x)) + O(x^40)) \\ Colin Barker, Jan 26 2018

Formula

a(n) = 2*(2^(n-1) + 2)*(2^(n-1) - 1) for n>=3. - Nathaniel Johnston, May 30 2011
a(0)=11, a(1)=36, a(2)=140, a(3)=540, a(n)=7*a(n-1)-14*a(n-2)+8*a(n-3). - Harvey P. Dale, Jun 10 2011
G.f.: x^2*(11 - 41*x + 42*x^2 - 24*x^3) / ((1 - x)*(1 - 2*x)*(1 - 4*x)). - Colin Barker, Jan 26 2018

Extensions

a(11)-a(27) and recurrence from Charles R Greathouse IV, May 29 2011

A191369 Numbers n with k divisors such that n-1 and n+1 in binary representation have same number k of 0's as 1's.

Original entry on oeis.org

11, 155, 203, 2164, 2228, 2252, 2276, 2348, 2404, 2452, 2468, 2588, 2612, 2636, 2644, 2675, 2708, 2763, 2836, 2891, 2979, 3148, 3179, 3236, 3275, 3283, 3411, 3475, 3716, 3971, 33723, 33755, 34235, 34523, 34539, 34715, 34771, 35315, 35563, 35571, 35787, 36155, 36411, 36507, 36555, 36579
Offset: 1

Views

Author

Juri-Stepan Gerasimov, Jun 04 2011

Keywords

Crossrefs

Programs

  • PARI
    isA191369(n)=my(b=vecsort(binary(n-1)),k=#b\2); #b==k+k & !b[k] & b[k+1] & b==vecsort(binary(n+1)) & numdiv(n)==k \\ Charles R Greathouse IV, Jun 05 2011

Extensions

a(10) corrected, a(31)-a(46) added by Charles R Greathouse IV, Jun 05 2011

A191534 Least k with 2n divisors such that k-1 and k+1 in binary representation have same number 2n of 0's as 1's.

Original entry on oeis.org

11, 155, 2164, 33723, 539379, 8396540, 136109403, 2147745531, 34360623100, 549771505659, 8797030442667, 140737513521148, 2251823188540923, 36028801313906427, 576460760876579772
Offset: 1

Views

Author

Juri-Stepan Gerasimov, Jun 05 2011

Keywords

Comments

Does a(n) exist for every n? It seems plausible at first glance; asymptotically there should be enough numbers in the range 16^n * [1/2, 1] that have 2n divisors (since 16 > e). [Charles R Greathouse IV, Jun 05 2011]
a(16) <= 9223372071079772155. - Donovan Johnson, Sep 25 2011

Crossrefs

Programs

  • PARI
    a(n)=my(v=vector(4*n,i,i>2*n));for(k=1<<(4*n-1)+1<<(2*n-1)-1,1<<(4*n)-1<<(2*n),if(vecsort(binary(k-1))==v & vecsort(binary(k+1))==v & numdiv(k)==2*n, return(k))) \\ Charles R Greathouse IV, Jun 05 2011

Extensions

a(5)-a(11) from Charles R Greathouse IV, Jun 05 2011
a(12)-a(15) from Donovan Johnson, Sep 25 2011

A191556 Largest k with 2n divisors such that the binary representations of k-1 and k+1 are in base 2 each digitally balanced with 4n digits.

Original entry on oeis.org

11, 203, 3971, 64771, 1011875, 16752659, 267475203, 4294709251, 68715414027, 1099495919619
Offset: 1

Views

Author

Juri-Stepan Gerasimov, Jun 05 2011

Keywords

Examples

			a(2) = 203 as 203 has 4 = 2*2 divisors and 202 and 204 are both balanced. - _David A. Corneth_, Apr 26 2022
		

Crossrefs

Formula

a(n) = Max_{k: k in A191292, A000005(k)=2n, A070939(k-1)=A070939(k+1)=4*n}. - R. J. Mathar, Jun 24 2011

Extensions

a(4)-a(6) from R. J. Mathar, Jun 24 2011
a(7)-a(10) from David A. Corneth, Apr 26 2022
Showing 1-7 of 7 results.