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.

A073138 Largest number having in its binary representation the same number of 0's and 1's as n.

Original entry on oeis.org

0, 1, 2, 3, 4, 6, 6, 7, 8, 12, 12, 14, 12, 14, 14, 15, 16, 24, 24, 28, 24, 28, 28, 30, 24, 28, 28, 30, 28, 30, 30, 31, 32, 48, 48, 56, 48, 56, 56, 60, 48, 56, 56, 60, 56, 60, 60, 62, 48, 56, 56, 60, 56, 60, 60, 62, 56, 60, 60, 62, 60, 62, 62, 63, 64, 96, 96, 112, 96, 112, 112
Offset: 0

Views

Author

Reinhard Zumkeller, Jul 16 2002

Keywords

Comments

From Trevor Green (green(AT)snoopy.usask.ca), Nov 26 2003: (Start)
a(n)/n has an accumulation point at x exactly when x is in the interval [1, 2]. Proof: Clearly n <= a(n) < 2n. Let b(n) = a(n)/n, then b(n) must always lie in [1,2) and all the accumulation points of the sequence must lie in [1,2]. We shall show that every such number is an accumulation point.
First, consider any d-bit integer n. Suppose that z of these bits are 0. Let n' be the (d+z)-bit integer whose first d bits are the same as those of n and whose remaining bits are all 1. Then a(n') will have to be the (d+z)-bit integer whose first d bits are all 1 and whose last z bits are all 0.
Thus n' = (n+1)*2^z-1; a(n') = (2^d-1)2^z; and b(n') = (2^d-1)/(n+1) + epsilon, where 0 < epsilon < 2^(1-d). So to get an accumulation point x, we just choose n(d) to be the d-bit integer such that (2^d-1)/(n(d)+1) < x <= (2^d-1)/n(d), or equivalently, n(d) = floor((2^d-1)/x). If x lies in [1,2), then n(d) will always be a d-bit number for sufficiently large d.
Then n'(d) yields an increasing subsequence of the integers for which b(n'(d)) converges to x. For x = 2, choose n(d) = 2^(d-1), which is always a d-bit number; then b(n'(d)) = (2^d-1)/(2^(d-1)+1) + epsilon = 2 + epsilon', where epsilon' also heads for 0 as d blows up. This proves the claim.
(End)

Examples

			a(20)=24, as 20='10100' and 24 is the greatest number having two 1's and three 0's: 17='10001', 18='10010', 20='10100' and 24='11000'.
		

Crossrefs

Cf. A030109.
Cf. A038573.
Decimal equivalent of A221714. - N. J. A. Sloane, Jan 26 2013

Programs

  • Haskell
    a073138 n = a038573 n * a080100 n  -- Reinhard Zumkeller, Jan 16 2012
    
  • Maple
    a:= n-> Bits[Join](sort(Bits[Split](n))):
    seq(a(n), n=0..100);  # Alois P. Heinz, Jun 26 2021
  • Mathematica
    f[n_] := Module[{idn=IntegerDigits[n, 2], o, l}, l=Length[idn]; o=Count[idn, 1]; FromDigits[Join[Table[1, {o}], Table[0, {l-o}]], 2]]; Table[f[i], {i, 0, 70}]
    ln[n_] := Module[{idn=IntegerDigits[n, 2], len, zer}, len=Length[idn]; zer=Count[idn, 0]; FromDigits[Join[Table[1, {len-zer}], Table[0, {zer}]], 2]]; Table[ln[i], {i, 0, 70}]
    a[z_] := 2^(Floor[Log[2, z]] + 1) * (1 - 2^(-Sum[k, {k, IntegerDigits[n, 2]}])) Column[Table[a[p], {p, 500}], Right] (* Trevor G. Hyde (thyde12(AT)amherst.edu), Jul 14 2008 *)
    Table[FromDigits[ReverseSort[IntegerDigits[n,2]],2],{n,0,70}] (* Harvey P. Dale, Mar 13 2023 *)
  • PARI
    a(n) = fromdigits(vecsort(binary(n),,4), 2); \\ Michel Marcus, Sep 26 2018
    
  • Python
    def a(n): return int("".join(sorted(bin(n)[2:], reverse=True)), 2)
    print([a(n) for n in range(71)]) # Michael S. Branicky, Jun 27 2021
    
  • Python
    def A073138(n): return (m:=1<>n.bit_count()) # Chai Wah Wu, Aug 18 2025

Formula

a(n+1) = a(floor(n/2))*2 + (n mod 2)*(2^floor(log_2(n)) - a(floor(n/2))); a(0)=0.
A023416(a(n)) = A023416(n), A000120(a(n)) = A000120(n).
a(0)=0, a(1)=1, a(2n) = 2a(n), a(2n+1) = a(n) + 2^floor(log_2(n)). - Ralf Stephan, Oct 05 2003
a(n) = 2^(floor(log_2(n)) + 1) * (1 - 2^(-d(n))) where d(n) = digit sum of base-2 expansion of n. - Trevor G. Hyde (thyde12(AT)amherst.edu), Jul 14 2008
a(n) = A038573(n) * A080100(n). - Reinhard Zumkeller, Jan 16 2012
n <= a(n) < 2n. - Charles R Greathouse IV, Aug 07 2024

A099627 Triangle read by rows: T(n,k) = 2^n + 2^k - 1 with n >= k >= 0.

Original entry on oeis.org

1, 2, 3, 4, 5, 7, 8, 9, 11, 15, 16, 17, 19, 23, 31, 32, 33, 35, 39, 47, 63, 64, 65, 67, 71, 79, 95, 127, 128, 129, 131, 135, 143, 159, 191, 255, 256, 257, 259, 263, 271, 287, 319, 383, 511, 512, 513, 515, 519, 527, 543, 575, 639, 767, 1023, 1024, 1025, 1027, 1031, 1039
Offset: 0

Views

Author

Henry Bottomley, Oct 25 2004

Keywords

Comments

Positive integers m where m-th Catalan number A000108(m) = C(2m,m)/(m+1) is not divisible by 4, i.e. where A048881(m) is 0 or 1.
Numbers in A000225 or A099628.
From Charles L. Hohn, Jul 25 2024: (Start)
Integers >=1 whose binary digit counts (number of 0s and number of 1s) are distinct from those of any smaller number.
Binary analog of A179239 for n>=1.
All integers whose binary expression conforms to regex /^10*1*$/, shown in base 10 in ascending numeric order. (End)
Together with 0 all fixed points of A073137. - Alois P. Heinz, Jan 30 2025

Examples

			Triangle starts:                  In binary:
   k = 0  1  2  3  4  5
n
0      1                               1
1      2  3                           10     11
2      4  5  7                       100    101    111
3      8  9 11 15                   1000   1001   1011   1111
4     16 17 19 23 31               10000  10001  10011  10111  11111
5     32 33 35 39 47 63           100000 100001 100011 100111 101111 111111
E.g. T(5,3) = 2^5 + 2^3-1 = 32 + 7 = 39 (100111 in binary).
		

Crossrefs

A053221 (row sums), A000079 (left diagonal), A000225 (right diagonal).
A048645 (see formula).
Partial sums of A232089.

Programs

  • Haskell
    a099627 n k = a099627_tabl !! n !! k
    a099627_row n = a099627_tabl !! n
    a099627_tabl = iterate (\xs@(x:_) -> (2 * x) : map ((+ 1) . (* 2)) xs) [1]
    -- Reinhard Zumkeller, Dec 19 2012
  • Mathematica
    Table[2^n+2^k -1,{n,0,10},{k,0,n}]//Flatten (* Harvey P. Dale, Mar 27 2016 *)

Formula

As sequence, a(n) = A048645(n+2) - 1.
G.f.: (1 - x - x^2*y)/((1 - x)*(1 - 2*x)*(1 - x*y)*(1 - 2*x*y)). - Stefano Spezia, Aug 11 2024

A073139 Difference between the largest and smallest number having in binary representation the same number of 0's and 1's as n.

Original entry on oeis.org

0, 0, 0, 0, 0, 1, 1, 0, 0, 3, 3, 3, 3, 3, 3, 0, 0, 7, 7, 9, 7, 9, 9, 7, 7, 9, 9, 7, 9, 7, 7, 0, 0, 15, 15, 21, 15, 21, 21, 21, 15, 21, 21, 21, 21, 21, 21, 15, 15, 21, 21, 21, 21, 21, 21, 15, 21, 21, 21, 15, 21, 15, 15, 0, 0, 31, 31, 45, 31, 45, 45, 49, 31, 45, 45, 49, 45, 49, 49, 45, 31
Offset: 0

Views

Author

Reinhard Zumkeller, Jul 16 2002

Keywords

Comments

a(n) = A073138(n) - A073137(n).

Crossrefs

Programs

  • Mathematica
    d[n_]:=Module[{idn2=IntegerDigits[n,2]},FromDigits[Sort[idn2,#1>#2&],2]- FromDigits[ RotateRight[Sort[idn2],1],2]]; Array[d,90,0] (* Harvey P. Dale, Oct 22 2011 *)

A073141 Product of the largest and smallest number having in binary representation the same number of 0's and 1's as n.

Original entry on oeis.org

0, 1, 4, 9, 16, 30, 30, 49, 64, 108, 108, 154, 108, 154, 154, 225, 256, 408, 408, 532, 408, 532, 532, 690, 408, 532, 532, 690, 532, 690, 690, 961, 1024, 1584, 1584, 1960, 1584, 1960, 1960, 2340, 1584, 1960, 1960, 2340, 1960, 2340, 2340, 2914, 1584, 1960
Offset: 0

Views

Author

Reinhard Zumkeller, Jul 16 2002

Keywords

Comments

a(n) = A073137(n) * A073138(n).

Crossrefs

Programs

  • Mathematica
    pls[n_]:=With[{d=FromDigits[#,2]&/@Select[Permutations[IntegerDigits[n,2]],#[[1]]==1&]},Max[d]Min[d]]; Join[{0},Array[pls,50]] (* Harvey P. Dale, May 29 2025 *)

A073140 Sum of the largest and smallest number having in binary representation the same number of 0's and 1's as n.

Original entry on oeis.org

0, 2, 4, 6, 8, 11, 11, 14, 16, 21, 21, 25, 21, 25, 25, 30, 32, 41, 41, 47, 41, 47, 47, 53, 41, 47, 47, 53, 47, 53, 53, 62, 64, 81, 81, 91, 81, 91, 91, 99, 81, 91, 91, 99, 91, 99, 99, 109, 81, 91, 91, 99, 91, 99, 99, 109, 91, 99, 99, 109, 99, 109, 109, 126, 128, 161, 161, 179
Offset: 0

Views

Author

Reinhard Zumkeller, Jul 16 2002

Keywords

Comments

a(n) = A073137(n) + A073138(n).

Crossrefs

A361479 a(n) is the least integer whose binary expansion has the same multiset of run-lengths as that of n.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 4, 7, 8, 9, 10, 9, 12, 9, 8, 15, 16, 17, 18, 19, 18, 21, 18, 17, 24, 19, 18, 19, 24, 17, 16, 31, 32, 33, 34, 35, 36, 37, 36, 35, 34, 37, 42, 37, 36, 37, 34, 33, 48, 35, 36, 51, 36, 37, 36, 35, 56, 35, 34, 35, 48, 33, 32, 63, 64, 65, 66, 67
Offset: 0

Views

Author

Rémy Sigrist, Mar 13 2023

Keywords

Crossrefs

Programs

  • PARI
    a(n) = { my (r=[]); while (n, my (v=valuation(n+n%2, 2)); n\=2^v; r=concat(v, r)); r=vecsort(r); my (h=0, t=#r+1, v=0); for (k=1, #r, v=(v+k%2)*2^if (k%2, r[h++], r[t--])-k%2;); return (v); }

Formula

a(a(n)) = a(n).
a(n) <= n with equality iff n = 0 or belongs to A175020.

A375216 n is the a(n)-th nonnegative integer having its multiset of binary digits.

Original entry on oeis.org

1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 3, 2, 3, 1, 1, 1, 2, 1, 3, 2, 3, 1, 4, 4, 5, 2, 6, 3, 4, 1, 1, 1, 2, 1, 3, 2, 3, 1, 4, 4, 5, 2, 6, 3, 4, 1, 5, 7, 8, 5, 9, 6, 7, 2, 10, 8, 9, 3, 10, 4, 5, 1, 1, 1, 2, 1, 3, 2, 3, 1, 4, 4, 5, 2, 6, 3, 4, 1, 5, 7, 8, 5, 9, 6, 7, 2, 10, 8, 9, 3, 10, 4, 5, 1, 6, 11, 12, 11, 13
Offset: 0

Views

Author

Alois P. Heinz, Jan 30 2025

Keywords

Examples

			a(26) = 5 because 26 is the 5th nonnegative integer having its multiset of binary digits: 19 = 10011_2, 21 = 10101_2, 22 = 10110_2, 25 = 11001_2, 26 = 11010_2.
		

Crossrefs

Cf. A073137.

Programs

  • Maple
    p:= proc() 0 end:
    a:= proc(n) option remember; local t;
          t:= sort(Bits[Split](n)); p(t):= p(t)+1
        end:
    seq(a(n), n=0..100);

Formula

Ordinal transform of A073137.
Showing 1-7 of 7 results.