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.

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.

This page as a plain text file.
%I A320037 #24 Nov 22 2018 18:53:57
%S A320037 2,9,6,17,38,25,14,33,70,153,78,49,102,57,30,65,134,281,142,305,614,
%T A320037 313,158,97,198,409,206,113,230,121,62,129,262,537,270,561,1126,569,
%U A320037 286,609,1222,2457,1230,625,1254,633,318,193,390,793,398,817,1638,825,414
%N 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.
%C A320037 A variation of A175046. Indices of record values are given by A319423.
%C A320037 From _Chai Wah Wu_, Nov 21 2018: (Start)
%C A320037 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.
%C A320037 Then f(k) = 16*6^(k-1) - 2^(k-1) for k > 0.
%C A320037 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.
%C A320037 (End)
%H A320037 Chai Wah Wu, <a href="/A320037/b320037.txt">Table of n, a(n) for n = 1..10000</a>
%H A320037 Chai Wah Wu, <a href="https://arxiv.org/abs/1810.02293">Record values in appending and prepending bitstrings to runs of binary digits</a>, arXiv:1810.02293 [math.NT], 2018.
%F A320037 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
%e A320037 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.
%o A320037 (Python)
%o A320037 from re import split
%o A320037 def A320037(n):
%o A320037     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)
%Y A320037 Cf. A175046, A319423, A320038.
%K A320037 nonn,base
%O A320037 1,1
%A A320037 _Chai Wah Wu_, Oct 04 2018