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-3 of 3 results.

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

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

Original entry on oeis.org

2, 8, 6, 16, 34, 24, 14, 32, 66, 136, 70, 48, 98, 56, 30, 64, 130, 264, 134, 272, 546, 280, 142, 96, 194, 392, 198, 112, 226, 120, 62, 128, 258, 520, 262, 528, 1058, 536, 270, 544, 1090, 2184, 1094, 560, 1122, 568, 286, 192, 386, 776, 390, 784, 1570, 792, 398
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 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) = 14.
Then f(k) = 15*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), a(4n+1) = 4*a(2n)+2, a(4n+2) = 4*a(2n+1) and a(4n+3) = 2*a(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) = 14 shows that f(k) = 15*6^(k-1) - 2^(k-1) for k > 0.
(End)

Examples

			6 in binary is 110. Modify each run by appending a 0 to get 11000, which is 24 in decimal. So a(6) = 24.
		

Crossrefs

Programs

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

Formula

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

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

Original entry on oeis.org

1, 4, 3, 8, 17, 12, 7, 16, 33, 68, 35, 24, 49, 28, 15, 32, 65, 132, 67, 136, 273, 140, 71, 48, 97, 196, 99, 56, 113, 60, 31, 64, 129, 260, 131, 264, 529, 268, 135, 272, 545, 1092, 547, 280, 561, 284, 143, 96, 193, 388, 195, 392, 785, 396, 199, 112, 225, 452, 227
Offset: 1

Views

Author

Chai Wah Wu, Oct 08 2018

Keywords

Comments

A variation of A175046. Indices of record values are given by A319423.

Examples

			6 in binary is 110. Modify each run by prepending a 0 to get 01100, which is 12 in decimal. So a(6) = 12.
		

Crossrefs

Programs

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

Formula

a(n) = A320262(n)/2.
Showing 1-3 of 3 results.