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.
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
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.
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
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
Comments