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.

A171598 Record values of A175047.

Original entry on oeis.org

1, 4, 8, 9, 12, 16, 17, 36, 68, 72, 73, 76, 100, 132, 136, 137, 140, 144, 145, 292, 548, 580, 584, 585, 588, 612, 804, 1060, 1092, 1096, 1097, 1100, 1124, 1156, 1160, 1161, 1164, 1168, 1169, 2340, 4388, 4644, 4676, 4680, 4681, 4684, 4708, 4900, 6436, 8484
Offset: 1

Views

Author

Reinhard Zumkeller, Dec 12 2009

Keywords

Comments

a(n)=A175047(A171599(n)) and A175047(m)A171599(n).

A171599 Where record values occur in A175047.

Original entry on oeis.org

1, 2, 4, 5, 6, 8, 9, 10, 18, 20, 21, 22, 26, 34, 36, 37, 38, 40, 41, 42, 74, 82, 84, 85, 86, 90, 106, 138, 146, 148, 149, 150, 154, 162, 164, 165, 166, 168, 169, 170, 298, 330, 338, 340, 341, 342, 346, 362, 426, 554, 586, 594, 596, 597, 598, 602, 618, 650, 658, 660
Offset: 1

Views

Author

Reinhard Zumkeller, Dec 12 2009

Keywords

Comments

A175047(a(n))=A171598(n) and A175047(m) < A171598(n) for m

A175046 Write n in binary, then increase each run of 0's by one 0, and increase each run of 1's by one 1. a(n) is the decimal equivalent of the result.

Original entry on oeis.org

3, 12, 7, 24, 51, 28, 15, 48, 99, 204, 103, 56, 115, 60, 31, 96, 195, 396, 199, 408, 819, 412, 207, 112, 227, 460, 231, 120, 243, 124, 63, 192, 387, 780, 391, 792, 1587, 796, 399, 816, 1635, 3276, 1639, 824, 1651, 828, 415, 224, 451, 908, 455, 920, 1843, 924
Offset: 1

Author

Leroy Quet, Dec 02 2009

Keywords

Comments

A318921 expands the runs in a similar way, and A318921(a(n)) = A001477(n). - Andrew Weimholt, Sep 08 2018
From Chai Wah Wu, Nov 18 2018: (Start)
Let f(k) = Sum_{i=2^k..2^(k+1)-1} a(i), i.e., the sum ranges over all numbers with a (k+1)-bit binary expansion. Thus f(0) = a(1) = 3 and f(1) = a(2) + a(3) = 19.
Then f(k) = 20*6^(k-1) - 2^(k-1) for k > 0.
Proof: by summing over the recurrence relations for a(n) (see formula section), we get f(k+2) = Sum_{i=2^k..2^(k+1)-1} (f(4i) + f(4i+1) + f(4i+2) + f(4i+3)) = Sum_{i=2^k..2^(k+1)-1} (6*a(2i) + 6*a(2i+1) + 4) = 6*f(k+1) + 2^(k+2). Solving this first-order recurrence relation with the initial condition f(1) = 19 shows that f(k) = 20*6^(k-1)-2^(k-1) for k > 0.
(End)

Examples

			6 in binary is 110. Increase each run by one digit to get 11100, which is 28 in decimal. So a(6) = 28.
		

Crossrefs

Cf. A175047, A175048, A324127 (partial sums).
For records see A319422, A319423, A319424.

Programs

  • Haskell
    import Data.List (group)
    a175046 = foldr (\b v -> 2 * v + b) 0 .
              concatMap (\bs@(b:_) -> b : bs) . group . a030308_row
    -- Reinhard Zumkeller, Jul 05 2013
    
  • Mathematica
    a[n_] := (Append[#, #[[1]]]& /@ Split[IntegerDigits[n, 2]]) // Flatten // FromDigits[#, 2]&;
    Array[a, 60] (* Jean-François Alcover, Nov 12 2018 *)
  • PARI
    A175046(n)={for(i=2,#n=binary (n*2+bittest (n,0)),n[i]!=n[i-1]&&n[i-1]*=[1,1]);fromdigits(concat(n),2)} \\ M. F. Hasler, Sep 08 2018
    
  • Python
    from re import split
    def A175046(n):
        return int(''.join(d+'1' if '1' in d else d+'0' for d in split('(0+)|(1+)',bin(n)[2:]) if d != '' and d != None),2) # Chai Wah Wu, Sep 24 2018
    
  • Python
    def a(n):
        b = bin(n)[2:]
        return int(b.replace("01", "001").replace("10", "110") + b[-1], 2)
    print([a(n) for n in range(1, 55)]) # Michael S. Branicky, Dec 07 2021

Formula

2n+1 <= a(n) < 2*(n+1/n)^2; a(n) mod 4 = 3*(n mod 2). - M. F. Hasler, Sep 08 2018
a(n) <= (9*n^2 + 12*n)/5, with equality iff n = (2/3)*(4^k-1) = A182512(k) for some k, i.e., n = 10101...10 in binary. - Conjectured by N. J. A. Sloane, Sep 09 2018, proved by M. F. Hasler, Sep 12 2018
From M. F. Hasler, Sep 12 2018: (Start)
Proof of N. J. A. Sloane's formula: For given (binary) length L(n) = floor(log_2(n)+1), the length of a(n) is maximal, L(a(n)) = 2*L(n), if and only if n's bits are alternating, i.e., n in A020988 (if even) or in A002450 (if odd).
For n = A020988(k) (= k times '10' in base 2) = (4^k - 1)*2/3, one has a(n) = A108020(k) (= k times '1100' in base 2) = (16^k - 1)*4/5. This yields a(n)/n = (4^k + 1)*6/5 = (n*9 + 12)/5, i.e., the given upper bound.
For n = A002450(k) = (4^k - 1)/3, one gets a(n) = A182512(k) = (16^k - 1)/5, whence a(n)/n = (4^k + 1)*3/5 = (n*9 + 6)/5, smaller than the bound.
If L(a(n)) < 2 L(n) - 1, then log_2(a(n)) < floor(log_2(a(n))+1) = L(a(n)) <= 2*L(n) - 2 = 2*floor(log_2(n)+1)-2 = 2*floor(log_2(n)) <= 2*log_2(n), whence a(n) < n^2.
It remains to consider the case L(a(n)) = 2 L(n) - 1. There are two possibilities:
If n = 10..._2, then n >= 2^(L(n)-1) and a(n) = 1100..._2 < 1101_2 * 2^(L(a(n))-4) = 13*2^(2*L(n)-5), so a(n)/n^2 < 13*2^(-5+2) = 13/8 = 1.625 < 9/5 = 1.8.
If n = 11..._2, then n >= 3*2^(L(n)-2) and a(n) = 111..._2 < 2^L(a(n)) = 2^(2*L(n)-1), so a(n)/n^2 < 2^(-1+4)/9 = 8/9 < 1 < 9/5.
This shows that a(n)/n^2 <= 9/5 + 12/(5*n) always holds, with equality iff n is in A020988; and a(n)/n^2 < 13/8 if n is not in A020988 or A002450. (End)
From M. F. Hasler, Sep 10 2018: (Start)
Right inverse of A318921: A318921 o A175046 = id (= A001477).
a(A020988(k)) = A108020(k); a(A002450(k)) = A182512(k); a(A000225(k)) = A000225(k+1) (achieves the lower bound a(n) >= 2n + 1) for all k >= 0. (End)
From David A. Corneth, Sep 20 2018: (Start)
a(4*k) = 2*a(2*k).
a(4*k+1) = 4*a(2*k) + 3.
a(4*k+2) = 4*a(2*k+1).
a(4*k+3) = 2*a(2*k+1) + 1. (End)

Extensions

Extended by Ray Chandler, Dec 18 2009

A033264 Number of blocks of {1,0} in the binary expansion of n.

Original entry on oeis.org

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

Keywords

Comments

Number of i such that d(i) < d(i-1), where Sum_{d(i)*2^i: i=0,1,....,m} is base 2 representation of n.
This is the base-2 down-variation sequence; see A297330. - Clark Kimberling, Jan 18 2017

Crossrefs

a(n) = A005811(n) - ceiling(A005811(n)/2) = A005811(n) - A069010(n).
Equals (A072219(n+1)-1)/2.
Cf. also A175047, A030308.
Essentially the same as A087116.

Programs

  • Haskell
    a033264 = f 0 . a030308_row where
       f c [] = c
       f c (0 : 1 : bs) = f (c + 1) bs
       f c (_ : bs) = f c bs
    -- Reinhard Zumkeller, Feb 20 2014, Jun 17 2012
    
  • Maple
    f:= proc(n) option remember; local k;
    k:= n mod 4;
    if k = 2 then procname((n-2)/4) + 1
    elif k = 3 then procname((n-3)/4)
    else procname((n-k)/2)
    fi
    end proc:
    f(1):= 0: f(0):= q:
    seq(f(i),i=1..100); # Robert Israel, Aug 31 2015
  • Mathematica
    Table[Count[Partition[IntegerDigits[n, 2], 2, 1], {1, 0}], {n, 102}] (* Michael De Vlieger, Aug 31 2015, after Robert G. Wilson v at A014081 *)
    Table[SequenceCount[IntegerDigits[n,2],{1,0}],{n,110}] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Jan 26 2017 *)
  • PARI
    a(n) = { hammingweight(bitand(n>>1, bitneg(n))) }; \\ Gheorghe Coserea, Aug 30 2015
    
  • Python
    def A033264(n): return ((n>>1)&~n).bit_count() # Chai Wah Wu, Jun 25 2025

Formula

G.f.: 1/(1-x) * Sum_(k>=0, t^2/(1+t)/(1+t^2), t=x^2^k). - Ralf Stephan, Sep 10 2003
a(n) = A069010(n) - (n mod 2). - Ralf Stephan, Sep 10 2003
a(4n) = a(4n+1) = a(2n), a(4n+2) = a(n)+1, a(4n+3) = a(n). - Ralf Stephan, Aug 20 2003
a(n) = A087116(n) for n > 0, since strings of 0's alternate with strings of 1's, which end in (1,0). - Jonathan Sondow, Jan 17 2016
Sum_{n>=1} a(n)/(n*(n+1)) = Pi/4 - log(2)/2 (A196521) (Allouche and Shallit, 1990). - Amiram Eldar, Jun 01 2021

A084471 Change 0 to 00 in binary representation of n.

Original entry on oeis.org

1, 4, 3, 16, 9, 12, 7, 64, 33, 36, 19, 48, 25, 28, 15, 256, 129, 132, 67, 144, 73, 76, 39, 192, 97, 100, 51, 112, 57, 60, 31, 1024, 513, 516, 259, 528, 265, 268, 135, 576, 289, 292, 147, 304, 153, 156, 79, 768, 385, 388, 195, 400, 201, 204, 103, 448, 225
Offset: 1

Author

Reinhard Zumkeller, May 27 2003

Keywords

Comments

a(n) = n iff n = 2^k - 1, k>0.
A023416(a(n))=A023416(n)*2; A000120(a(n))=A000120(n);

Crossrefs

Cf. A084472(n)=A007088(a(n)), A084473, A038573.
Ordered terms are in A060142.
Column k=2 of A340666.
Cf. A088698, A175047. - Robert G. Wilson v, Dec 10 2009

Programs

  • Haskell
    a084471 1 = 1
    a084471 x = 2 * (2 - d) * a084471 x' + d  where (x',d) = divMod x 2
    -- Reinhard Zumkeller, Jul 16 2012
  • Maple
    a:= n-> Bits[Join](subs(0=[0$2][], Bits[Split](n))):
    seq(a(n), n=1..60);  # Alois P. Heinz, Jan 15 2021
  • Mathematica
    f[n_] := FromDigits[Flatten[IntegerDigits[n, 2] /. {0 -> {0, 0}}], 2]; Array[f, 60] (* Robert G. Wilson v, Dec 10 2009 *)

Formula

a(1)=1, a(2*k+1)=2*a(k)+1, a(2*k)=4*a(k).

A106151 In binary representation of n: delete one zero in each contiguous block of zeros.

Original entry on oeis.org

1, 1, 3, 2, 3, 3, 7, 4, 5, 3, 7, 6, 7, 7, 15, 8, 9, 5, 11, 6, 7, 7, 15, 12, 13, 7, 15, 14, 15, 15, 31, 16, 17, 9, 19, 10, 11, 11, 23, 12, 13, 7, 15, 14, 15, 15, 31, 24, 25, 13, 27, 14, 15, 15, 31, 28, 29, 15, 31, 30, 31, 31, 63, 32, 33, 17, 35, 18, 19, 19, 39, 20, 21, 11, 23, 22, 23
Offset: 1

Author

Reinhard Zumkeller, May 07 2005

Keywords

Comments

Equivalently, change bits 10 -> 0. - Michael S. Branicky, Nov 12 2021

Examples

			n=144 = '10010000' -> '101000' = 40 = a(144);
n=145 = '10010001' -> '101001' = 41 = a(145);
n=146 = '10010010' -> '10101'  = 21 = a(146).
		

Programs

  • Haskell
    import Data.List (group)
    a106151 = foldr (\b v -> 2 * v + b) 0 . concatMap
       (\bs'@(b:bs) -> if b == 0 then bs else bs') . group . a030308_row
    -- Reinhard Zumkeller, Jul 05 2013
    
  • PARI
    A106151(n) = if(n<=1, n, if(n%2, 1+(2*A106151((n-1)/2)), A106151(n>>valuation(n, 2))<<(valuation(n, 2)-1))); \\ Antti Karttunen, May 13 2018
    
  • PARI
    A106151(n) = { my(s=0, i=0); while(n, if(2!=(n%4), s += (n%2)<>= 1); (s); }; \\ Antti Karttunen, Jul 01 2024
    
  • Python
    def a(n): return int(bin(n).replace("b", "").replace("10", "1"), 2)
    print([a(n) for n in range(1, 78)]) # Michael S. Branicky, Nov 12 2021

Formula

a(n) <= n; a(n) = n iff n = 2^k-1: a(A000225(n))=A000225(n);
A000120(a(n)) = A000120(n);
A023416(a(n)) = A023416(n) - A087116(n).
a(n) = b(n, 0), where b(n, r) = if n = 1 then 1 else b(floor(n/2), 1 - n mod 2)*(1 + floor((1 + r + n mod 2)/2)) + n mod 2.
For n <= 1, a(n) = n, and for n > 1, if n is odd, then a(n) = 1+2*a((n-1)/2), otherwise, when n is even, a(n) = (2^(A007814(n)-1)) * a(A000265(n)). - Antti Karttunen, May 13 2018

A175048 Write n in binary, then increase each run of 1's by one 1. a(n) is the decimal equivalent of the result.

Original entry on oeis.org

3, 6, 7, 12, 27, 14, 15, 24, 51, 54, 55, 28, 59, 30, 31, 48, 99, 102, 103, 108, 219, 110, 111, 56, 115, 118, 119, 60, 123, 62, 63, 96, 195, 198, 199, 204, 411, 206, 207, 216, 435, 438, 439, 220, 443, 222, 223, 112, 227, 230, 231, 236, 475, 238, 239, 120, 243, 246
Offset: 1

Author

Leroy Quet, Dec 02 2009

Keywords

Examples

			12 in binary is 1100. Increase each run of 1 by one digit to get 11100, which is 28 in decimal. So a(12) = 28.
		

Crossrefs

Programs

  • Haskell
    import Data.List (group)
    a175048 = foldr (\b v -> 2 * v + b) 0 . concatMap
       (\bs@(b:_) -> if b == 1 then 1 : bs else bs) . group . a030308_row
    -- Reinhard Zumkeller, Jul 05 2013
    
  • Mathematica
    Table[FromDigits[Flatten[If[MemberQ[#,1],Join[{1},#],#]&/@ Split[ IntegerDigits[ n,2]]],2],{n,60}] (* Harvey P. Dale, Oct 10 2013 *)
  • Python
    def a(n): return int(("0"+bin(n)[2:]).replace("01", "011"), 2)
    print([a(n) for n in range(1, 61)]) # Michael S. Branicky, Jul 27 2022

Formula

a(2^n) = 3*2^n. a(4n) = 2*a(2n), a(4n+1) = 4*a(2n)+3, a(4n+2) = 2*a(2n+1), a(4n+3) = 2*a(2n+1)+1. - Chai Wah Wu, Nov 21 2018

Extensions

Extended by Ray Chandler, Dec 18 2009

A266150 Take the binary representation of n, increase each run of 0's by one 0 if the length of run is odd, otherwise, if length of run is even, remove one 0. a(n) is the decimal equivalent of the result.

Original entry on oeis.org

0, 1, 4, 3, 2, 9, 12, 7, 16, 5, 36, 19, 6, 25, 28, 15, 8, 33, 20, 11, 18, 73, 76, 39, 48, 13, 100, 51, 14, 57, 60, 31, 64, 17, 132, 67, 10, 41, 44, 23, 144, 37, 292, 147, 38, 153, 156, 79, 24, 97, 52, 27, 50, 201, 204, 103, 112, 29, 228, 115, 30, 121, 124, 63, 32
Offset: 0

Author

Alex Ratushnyak, Dec 21 2015

Keywords

Comments

This is a self-inverse permutation of the positive integers.

Examples

			a(4) = 2 since 4 = 100 binary -> 10 = 2 decimal.
a(5) = 9 since 5 = 101 binary -> 1001 = 9 decimal.
a(6) = 12 since 6 = 110 binary -> 1100 = 12 decimal.
		

Programs

  • Mathematica
    Table[FromDigits[#, 2] &@ Flatten[If[First@ # == 0, If[OddQ@ Length@ #, Append[IntegerDigits@ #, 0], Most@ IntegerDigits@ #], #] & /@ Split@ IntegerDigits[n, 2]], {n, 64}] (* Michael De Vlieger, Dec 22 2015 *)
  • PARI
    a(n) = if (n==0, 0, my (b=n%2, r=valuation(n+b, 2), rr=if (b, r, r%2, r+1, r-1)); (a(n\2^r)+b)*2^rr-b) \\ Rémy Sigrist, Jan 20 2019

Extensions

a(0) = 0 prepended by Rémy Sigrist, Jan 20 2019

A266151 Take the binary representation of n, increase each run of 1's by one 1 if the length of run is odd, otherwise, if length of run is even, remove one 1. a(n) is the decimal equivalent of the result.

Original entry on oeis.org

0, 3, 6, 1, 12, 27, 2, 15, 24, 51, 54, 13, 4, 11, 30, 7, 48, 99, 102, 25, 108, 219, 26, 111, 8, 19, 22, 5, 60, 123, 14, 63, 96, 195, 198, 49, 204, 411, 50, 207, 216, 435, 438, 109, 52, 107, 222, 55, 16, 35, 38, 9, 44, 91, 10, 47, 120, 243, 246, 61, 28, 59, 126, 31
Offset: 0

Author

Alex Ratushnyak, Dec 21 2015

Keywords

Comments

This is a self-inverse permutation of the positive integers.

Examples

			a(4) = 12 since 4 = 100 binary -> 1100 = 12 decimal,
a(5) = 27 since 5 = 101 binary -> 110011 = 27 decimal,
a(6) = 2 since 6 = 110 binary -> 10 = 2 decimal.
		

Programs

  • Mathematica
    Table[FromDigits[#, 2] &@ Flatten[If[First@ # == 1, If[OddQ@ Length@ #, Append[IntegerDigits@ #, 1], Most@ IntegerDigits@ #], #] & /@ Split@ IntegerDigits[n, 2]], {n, 63}] (* Michael De Vlieger, Dec 22 2015 *)
  • PARI
    a(n) = if (n==0, 0, my (b=n%2, r=valuation(n+b, 2), rr=if (b==0, r, r%2, r+1, r-1)); (a(n\2^r)+b)*2^rr-b) \\ Rémy Sigrist, Jan 20 2019

Extensions

a(0) = 0 prepended by Rémy Sigrist, Jan 20 2019
Showing 1-9 of 9 results.