login
Write n in binary, then increase each run of 1's by one 1. a(n) is the decimal equivalent of the result.
6

%I #23 Jul 28 2022 09:23:34

%S 3,6,7,12,27,14,15,24,51,54,55,28,59,30,31,48,99,102,103,108,219,110,

%T 111,56,115,118,119,60,123,62,63,96,195,198,199,204,411,206,207,216,

%U 435,438,439,220,443,222,223,112,227,230,231,236,475,238,239,120,243,246

%N Write n in binary, then increase each run of 1's by one 1. a(n) is the decimal equivalent of the result.

%H Reinhard Zumkeller, <a href="/A175048/b175048.txt">Table of n, a(n) for n = 1..10000</a>

%F 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

%e 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.

%t Table[FromDigits[Flatten[If[MemberQ[#,1],Join[{1},#],#]&/@ Split[ IntegerDigits[ n,2]]],2],{n,60}] (* _Harvey P. Dale_, Oct 10 2013 *)

%o (Haskell)

%o import Data.List (group)

%o a175048 = foldr (\b v -> 2 * v + b) 0 . concatMap

%o (\bs@(b:_) -> if b == 1 then 1 : bs else bs) . group . a030308_row

%o -- _Reinhard Zumkeller_, Jul 05 2013

%o (Python)

%o def a(n): return int(("0"+bin(n)[2:]).replace("01", "011"), 2)

%o print([a(n) for n in range(1, 61)]) # _Michael S. Branicky_, Jul 27 2022

%Y Cf. A175046, A175047, A348710.

%Y Cf. A030308, A007088.

%K base,nonn

%O 1,1

%A _Leroy Quet_, Dec 02 2009

%E Extended by _Ray Chandler_, Dec 18 2009