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.

Previous Showing 11-20 of 27 results. Next

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

Views

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

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

Original entry on oeis.org

2, 9, 6, 17, 38, 25, 14, 33, 70, 153, 78, 49, 102, 57, 30, 65, 134, 281, 142, 305, 614, 313, 158, 97, 198, 409, 206, 113, 230, 121, 62, 129, 262, 537, 270, 561, 1126, 569, 286, 609, 1222, 2457, 1230, 625, 1254, 633, 318, 193, 390, 793, 398, 817, 1638, 825, 414
Offset: 1

Views

Author

Chai Wah Wu, Oct 04 2018

Keywords

Comments

A variation of A175046. Indices of record values are given by A319423.
From Chai Wah Wu, Nov 21 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) = 2 and f(1) = a(2) + a(3) = 15.
Then f(k) = 16*6^(k-1) - 2^(k-1) for k > 0.
Proof: looking at the last 2 bits of n, it is easy to see that a(4n) = 2a(2n)-1, a(4n+1) = 4a(2n)+2, a(4n+2) = 4a(2n+1)+1 and a(4n+3) = 2a(2n+1)+2. By summing over the recurrence relations for a(n), 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} (6a(2i) + 6a(2i+1) + 4) = 6*f(k+1) + 2^(k+2). Solving this first order recurrence relation with the initial condition f(1) = 15 shows that f(k) = 16*6^(k-1) - 2^(k-1) for k > 0.
(End)

Examples

			6 in binary is 110. Modify each run by appending the opposite digit to get 11001, which is 25 in decimal. So a(6) = 25.
		

Crossrefs

Programs

  • Python
    from re import split
    def A320037(n):
        return int(''.join(d+'0' if '1' in d else d+'1' for d in split('(0+)|(1+)',bin(n)[2:]) if d != '' and d != None),2)

Formula

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

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

Original entry on oeis.org

1, 6, 3, 12, 25, 14, 7, 24, 49, 102, 51, 28, 57, 30, 15, 48, 97, 198, 99, 204, 409, 206, 103, 56, 113, 230, 115, 60, 121, 62, 31, 96, 193, 390, 195, 396, 793, 398, 199, 408, 817, 1638, 819, 412, 825, 414, 207, 112, 225, 454, 227, 460, 921, 462, 231, 120, 241
Offset: 1

Views

Author

Chai Wah Wu, Oct 04 2018

Keywords

Comments

A variation of A175046. Indices of record values are given by A319423.
From Chai Wah Wu, Nov 25 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) = 1 and f(1) = a(2) + a(3) = 9.
Then f(k) = 10*6^(k-1) - 2^(k-1) for k > 0.
Proof: looking at the last 2 bits of n, it is easy to see that a(4n) = 2*a(2n), a(4n+1) = 4*a(2n)+1, a(4n+2) = 4*a(2n+1)+2 and a(4n+3) = 2*a(2n+1)+1. By summing over the recurrence relations for a(n), 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} (6a(2i) + 6a(2i+1) + 4) = 6*f(k+1) + 2^(k+2). Solving this first-order recurrence relation with the initial condition f(1) = 9 shows that f(k) = 10*6^(k-1) - 2^(k-1) for k > 0.
(End)

Examples

			6 in binary is 110. Modify each run by prepending the opposite digit to get 01110, which is 14 in decimal. So a(6) = 14.
		

Crossrefs

Programs

  • Mathematica
    a[n_] := Split[IntegerDigits[n, 2]] /. {a0:{(0)...} :> Prepend[a0, 1], a1:{(1)...} :> Prepend[a1, 0]} // Flatten // FromDigits[#, 2]&;
    Array[a, 60] (* Jean-François Alcover, Dec 02 2018 *)
  • Python
    from re import split
    def A320038(n):
        return int(''.join('0'+d if '1' in d else '1'+d for d in split('(0+)|(1+)',bin(n)[2:]) if d != '' and d != None),2)

Formula

a(n) = floor(A175046(n)/2).
a(4n) = 2*a(2n), a(4n+1) = 4*a(2n)+1, a(4n+2) = 4*a(2n+1)+2 and a(4n+3) = 2*a(2n+1)+1. - Chai Wah Wu, Nov 25 2018

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

Original entry on oeis.org

3, 13, 7, 25, 55, 29, 15, 49, 103, 221, 111, 57, 119, 61, 31, 97, 199, 413, 207, 441, 887, 445, 223, 113, 231, 477, 239, 121, 247, 125, 63, 193, 391, 797, 399, 825, 1655, 829, 415, 881, 1767, 3549, 1775, 889, 1783, 893, 447, 225, 455, 925, 463, 953, 1911, 957
Offset: 1

Views

Author

Chai Wah Wu, Oct 05 2018

Keywords

Comments

A variation of A175046. Indices of record values are given by A319423.
From Chai Wah Wu, Nov 21 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) = 20.
Then f(k) = 21*6^(k-1) - 2^(k-1) for k >= 0.
Proof: the equation for f is true for k = 0. Looking at the last 2 bits of n, it is easy to see that a(4n) = 2*a(2n)-1, a(4n+1) = 4*a(2n)+3, a(4n+2) = 4*a(2n+1)+1 and a(4n+3) = 2*a(2n+1)+1. By summing over the recurrence relations for a(n), 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} (6a(2i) + 6a(2i+1) + 4) = 6*f(k+1) + 2^(k+2). Solving this first-order recurrence relation with the initial condition f(1) = 20 shows that f(k) = 21*6^(k-1) - 2^(k-1) for k > 0.
(End)

Examples

			6 in binary is 110. Modify each run by appending a 1 to get 11101, which is 29 in decimal. So a(6) = 29.
		

Crossrefs

Programs

  • Mathematica
    Array[FromDigits[Flatten@ Map[Append[#, 1] &, Split@ IntegerDigits[#, 2]], 2] &, 54] (* Michael De Vlieger, Nov 23 2018 *)
  • Python
    from re import split
    def A320039(n):
        return int(''.join(d+'1' for d in split('(0+)|(1+)',bin(n)[2:]) if d != '' and d != None),2)

Formula

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

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

Views

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.
		

Crossrefs

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

Views

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.
		

Crossrefs

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

A319419 In binary expansion of n, delete one symbol from each run. Set a(n)=-1 if the result is the empty string.

Original entry on oeis.org

-1, -1, -1, 1, 0, -1, 1, 3, 0, 0, -1, 1, 2, 1, 3, 7, 0, 0, 0, 1, 0, -1, 1, 3, 4, 2, 1, 3, 6, 3, 7, 15, 0, 0, 0, 1, 0, 0, 1, 3, 0, 0, -1, 1, 2, 1, 3, 7, 8, 4, 2, 5, 2, 1, 3, 7, 12, 6, 3, 7, 14, 7, 15, 31, 0, 0, 0, 1, 0, 0, 1, 3, 0, 0, 0, 1, 2, 1, 3, 7, 0, 0
Offset: 0

Views

Author

N. J. A. Sloane, Sep 21 2018

Keywords

Comments

If the binary expansion of n is 1^b 0^c 1^d 0^e ..., then a(n) is the number whose binary expansion is 1^(b-1) 0^(c-1) 1^(d-1) 0^(e-1) .... Leading 0's are omitted, and if the result is the empty string, here we set a(n) = -1. See A318921 for a version which represents the empty string by 0.
Lenormand refers to this operation as planing ("raboter") the runs (or blocks) of the binary expansion.
A175046 expands the runs in a similar way, and a(A175046(n)) = A001477(n). - Andrew Weimholt, Sep 08 2018 (Comment copied from A318921.)
a(n) = -1 iff n in A000975.

Examples

			n / "planed" string / a(n)
0 e -1 (e = empty string)
1 e -1
10 e -1
11 1 1
100 0 0
101 e -1
110 1 1
111 11 3
1000 00 0
1001 0 0
1010 e -1
1011 1 1
1100 10 2
1101 1 1
1110 11 3
1111 111 7
10000 000 0
...
		

Crossrefs

Programs

  • Maple
    r:=proc(n) local t1, t2, L, len, i, j, k, b1;
    if n <= 2 then return(-1); fi;
    b1:=[]; t1:=convert(n, base, 2); L:=nops(t1); p:=1; len:=1;
    for i from 2 to L do
    t2:=t1[L+1-i];
    if (t2=p) and (i1 then for j from 1 to len-1 do b1:=[op(b1), p]; od: fi;
       p:=t2; len:=1;
    fi;               od;
    if nops(b1)=0 then return(-1);
    else k:=b1[1];
    for i from 2 to nops(b1) do k:=2*k+b1[i]; od;
    return(k);
    fi;
    end;
    [seq(r(n), n=0..120)];
  • Python
    from re import split
    def A319419(n):
        s = ''.join(d[:-1] for d in split('(0+)|(1+)',bin(n)[2:]) if d not in {'','0','1',None})
        return -1 if s == '' else int(s,2) # Chai Wah Wu, Sep 24 2018
    
  • Python
    from itertools import groupby
    def a(n):
        s = "".join(k*(len(list(g))-1) for k, g in groupby(bin(n)[2:]))
        return int(s, 2) if s != "" else -1
    print([a(n) for n in range(82)]) # Michael S. Branicky, Jun 01 2025

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

Original entry on oeis.org

3, 14, 7, 28, 59, 30, 15, 56, 115, 238, 119, 60, 123, 62, 31, 112, 227, 462, 231, 476, 955, 478, 239, 120, 243, 494, 247, 124, 251, 126, 63, 224, 451, 910, 455, 924, 1851, 926, 463, 952, 1907, 3822, 1911, 956, 1915, 958, 479, 240, 483, 974, 487, 988, 1979, 990
Offset: 1

Views

Author

Chai Wah Wu, Oct 08 2018

Keywords

Comments

A variation of A175046. Indices of record values are given by A319423.
From Chai Wah Wu, Nov 25 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) = 21, and f(2) = a(4)+a(5)+a(6)+a(7) = 132.
Then f(k) = 135*6^(k-2) - 3*2^(k-2) for k >= 0.
Proof: the formula is true for k = 0. Looking at the last 2 bits of n, it is easy to see that a(4n) = 2*a(2n), a(4n+1) = 4*a(2n)+3, a(4n+2) = 4*a(2n+1)+2 and a(4n+3) = 2*a(2n+1)+1. By summing over the recurrence relations for a(n), 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} (6a(2i) + 6a(2i+1) + 6) = 6*f(k+1) + 3*2^(k+1). Solving this first-order recurrence relation with the initial condition f(1) = 21 shows that f(k) = 135*6^(k-2) - 3*2^(k-2) for k > 0.
(End)

Examples

			6 in binary is 110. Modify each run by prepending a 1 to get 11110, which is 30 in decimal. So a(6) = 30.
		

Crossrefs

Programs

  • Mathematica
    Table[FromDigits[Flatten[Join[{1},#]&/@Split[IntegerDigits[n,2]]],2],{n,60}] (* Harvey P. Dale, Apr 26 2019 *)
  • Python
    from re import split
    def A320261(n):
        return int(''.join('1'+d for d in split('(0+)|(1+)',bin(n)[2:]) if d != '' and d != None),2)

Formula

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

A321003 a(n) = 2^n*(4*3^n-1).

Original entry on oeis.org

3, 22, 140, 856, 5168, 31072, 186560, 1119616, 6718208, 40310272, 241863680, 1451186176, 8707125248, 52242767872, 313456640000, 1880739905536, 11284439564288, 67706637647872, 406239826411520, 2437438959517696, 14624633759203328, 87747802559414272
Offset: 0

Views

Author

N. J. A. Sloane, Nov 01 2018

Keywords

Comments

Conjectured to be the sum of A175046(i) for 1 <= i < 2^(n+1).

Crossrefs

Programs

  • Maple
    a := n -> 2^n*(4*3^n-1):
    seq(a(n), n = 0 .. 25); # Stefano Spezia, Nov 02 2018
  • Mathematica
    a[n_]:=2^n*(4*3^n-1); Array[a, 25, 0] (* or *)
    CoefficientList[Series[-E^(2 x) + 4 E^(6 x), {x, 0, 25}], x]*Table[k!, {k, 0, 25}] (* Stefano Spezia, Nov 02 2018 *)
  • PARI
    Vec((3 - 2*x) / ((1 - 2*x)*(1 - 6*x)) + O(x^25)) \\ Colin Barker, Nov 02 2018
    
  • PARI
    a(n) = 2^n*(4*3^n-1); \\ Michel Marcus, Nov 02 2018

Formula

From Colin Barker, Nov 02 2018: (Start)
G.f.: (3 - 2*x) / ((1 - 2*x)*(1 - 6*x)).
a(n) = 8*a(n-1) - 12*a(n-2) for n>1.
(End)
E.g.f.: -exp(2*x)+4*exp(6*x). - Stefano Spezia, Nov 02 2018

A321536 Write n in base 10, lengthen all the runs of successive identical digits by 1.

Original entry on oeis.org

0, 11, 22, 33, 44, 55, 66, 77, 88, 99, 1100, 111, 1122, 1133, 1144, 1155, 1166, 1177, 1188, 1199, 2200, 2211, 222, 2233, 2244, 2255, 2266, 2277, 2288, 2299, 3300, 3311, 3322, 333, 3344, 3355, 3366, 3377, 3388, 3399, 4400, 4411, 4422, 4433, 444, 4455, 4466
Offset: 0

Views

Author

N. J. A. Sloane, Nov 13 2018

Keywords

Comments

A321537(a(n)) = n. Compare A321538.

Examples

			10 -> 1100, so a(10)=1100; 11->111, so a(11)=111.
		

Crossrefs

A base-10 analog of A175046.

Programs

  • Mathematica
    a[n_] := FromDigits@ Flatten[ Append[ #, Last@#] & /@ Split@ IntegerDigits[ n]]; a /@ Range[0, 46] (* Giovanni Resta, Nov 13 2018 *)
  • PARI
    a(n)={my(v=digits(n)); my(L=List()); for(i=1, #v, my(t=v[i]); if(i==1 || t<>v[i-1], listput(L,t)); listput(L,t)); fromdigits(Vec(L))} \\ Andrew Howroyd, Nov 13 2018
  • Python
    from re import split
    def A321536(n):
        return int(''.join(d+d[0] for d in split('(0+)|(1+)|(2+)|(3+)|(4+)|(5+)|(6+)|(7+)|(8+)|(9+)',str(n)) if d != '' and d != None)) # Chai Wah Wu, Nov 13 2018
    

Extensions

More terms from Giovanni Resta, Nov 13 2018
Previous Showing 11-20 of 27 results. Next