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.
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
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.
Links
- Chai Wah Wu, Table of n, a(n) for n = 1..10000
- Chai Wah Wu, Record values in appending and prepending bitstrings to runs of binary digits, arXiv:1810.02293 [math.NT], 2018.
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
Comments