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.

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

A144812 Integers having ideal digital mean up to base 7.

Original entry on oeis.org

36990, 37230, 43350, 45390, 2149023720, 2149218300, 2149279740, 2149513020, 2149527540, 2149545960, 2151079740, 2151628020, 2151662460, 2151667320, 2152716540, 2152720860, 2152724280, 2153463540, 2154166200, 2154948600, 2155019220, 2155051980, 2155196340
Offset: 1

Views

Author

Reikku Kulon, Sep 21 2008

Keywords

Comments

These numbers have digital mean dm(b, n) = (Sum_{i=1..d} 2*d_i - (b-1)) / (2*d) = 0, where d is the number of digits in the base b representation of n and d_i the individual digits, for 2 <= b <= 7.
There are no integers less than 2^32 for which this is true to base 8. It is believed there are either infinitely many starting at some larger n, or none. If they exist, it is conjectured that the set of all similar sequences continues at least to base ten, almost certainly to base 16 and likely to arbitrarily large b. Sequences for b at least ten have an intersection with A144777.

Crossrefs

A144912 Unreduced numerators of digital mean, dm_num(b, n), with rows n in {2, 3, 4, ...} and columns b in {2, 3, 4, ..., n}.

Original entry on oeis.org

0, 2, -2, -1, 0, -4, 1, 2, -2, -6, 1, 0, 0, -4, -8, 3, 2, 2, -2, -6, -10, -2, 4, -2, 0, -4, -8, -12, 0, -4, 0, 2, -2, -6, -10, -14, 0, -2, 2, -4, 0, -4, -8, -12, -16, 2, 0, 4, -2, 2, -2, -6, -10, -14, -18, 0, -2, 0, 0, -6, 0, -4, -8, -12, -16, -20
Offset: 2

Views

Author

Reikku Kulon, Sep 25 2008, Oct 03 2008

Keywords

Comments

The unreduced numerator of dm(b, n) is Sum_{i=1..d} (2*d_i - (b-1)), where d is the number of digits in the base b representation of n and d_i the individual digits. The corresponding denominator is 2 * d, giving a value in (-(b - 1) / 2, (b - 1) / 2] for n > 0.
dm_num(b, n) = d(b - 1) iff all the digits in n are b - 1.
dm_num(b, n) = -2(b - 2) for b = n, because n in base n is 10, giving dm_num(n, n) = 2 - n + 1 + 0 - n + 1 = 4 - 2 * n = -2(n - 2).
dm_num(b, n) = 0 for odd b and n having all digits equal to (b - 1) / 2, as well as for many other (b, n).
Defining m = ceiling((n + 1) / 2):
dm_num(b, n) = dm_num(b - 1, n) - 4 for b in [m + 1, n].
dm_num(m, n) = 0 for even n and 2 for odd n.
dm_num(m - 1, n) = 6 - n for even n > 4 and 9 - n for odd n > 5, producing a sequence of first differences {+2, -4, +2, -4, ...}.
Triangular patterns become clearly visible for large n, defined by additive periodicities along rational slopes. Zeros along the triangle borders correspond to ones in the Redheffer matrix until odd values become dominant. The line along m is the border between the two largest triangles. This pattern is masked by aliasing effects for small bases, notably including base 10, due to the thinness of the triangles which dominate at small b. Odd values may represent "artifacts" caused by "interference".

Examples

			Triangle begins:
   0;
   2, -2;
  -1,  0, -4;
   1,  2, -2, -6;
   1,  0,  0, -4, -8;
   3,  2,  2, -2, -6, -10;
   ...
		

Crossrefs

Programs

  • Mathematica
    dmnum[b_,n_]:=2Total[IntegerDigits[n,b]]-(b-1)Floor[Log[b,n*b]]; (* after Jinyuan Wang *)
    Table[dmnum[b,n],{n,2,10},{b,2,n}] (* Paolo Xausa, Sep 26 2023 *)
  • PARI
    dm(b, n) = 2*sumdigits(n, b) - (b-1)*logint(n*b, b); \\ Jinyuan Wang, Jul 21 2020

A364714 Least positive integer whose average digit in base b equals (b-1)/2 (the expected value for random digits) for 2 <= b <= n.

Original entry on oeis.org

2, 38, 141, 3468, 36990, 36990
Offset: 2

Views

Author

Pontus von Brömssen, Aug 04 2023

Keywords

Comments

a(n) has an even number of digits in all even bases b <= n.
a(8) <= 795482814912042180, a(9) and a(10) <= 836119295625913740. - Giorgos Kalogeropoulos, Aug 09 2023
a(8) and a(9) <= 789730327537467540, a(10) <= 789731071815355740, a(11) <= 789731549802436500. - Jason Yuen, May 17 2024
a(8) > A144812(10000) = 16960567248690 (last term in b-file for A144812). - Pontus von Brömssen, May 19 2024

Examples

			For n = 4, 141 is 10001101 in binary with average digit 1/2, 12020 in base 3 with average digit 2/2 = 1, and 2031 in base 4 with average digit 3/2. No smaller number has this property, so a(4) = 141.
		

Crossrefs

a(2)-a(7) are the first terms of A031443, A144798, A144799, A144800, A144801, and A144812, respectively.

Programs

  • PARI
    isokb(k, b) = my(d=digits(k,b)); vecsum(d)/#d == (b-1)/2;
    isok(k, n) = for (b=2, n, if (!isokb(k, b), return(0));); 1;
    a(n) = my(k=1); while (!isok(k, n), k++); k; \\ Michel Marcus, Aug 05 2023
Showing 1-4 of 4 results.