OFFSET
1,2
COMMENTS
LINKS
R. Zumkeller, Table of n, a(n) for n = 1..10000
FORMULA
a(n) = if n<2 then n else 2*(1 + 0^((n+2) mod 4))*a([n/2]) + n mod 2. - Reinhard Zumkeller, Jan 20 2010
a(2^n) = 2^(n+1). - Chai Wah Wu, Nov 21 2018
EXAMPLE
12 in binary is 1100. Increase each run of 0 by one digit to get 11000, which is 24 in decimal. So a(12) = 24.
MATHEMATICA
f[n_] := Block[{s = Split@ IntegerDigits[n, 2]}, FromDigits[ Flatten@ Insert[s, {0}, Table[{2 i}, {i, Floor[ Length@s/2]} ]], 2]]; Arrar[ f, 64] (* Robert G. Wilson v, Dec 11 2009 *)
PROG
(Haskell)
import Data.List (group)
a175047 = foldr (\b v -> 2 * v + b) 0 . concatMap
(\bs@(b:_) -> if b == 0 then 0 : bs else bs) . group . a030308_row
-- Reinhard Zumkeller, Jul 05 2013
(Python)
from re import split
def A175047(n):
return int(''.join(d+'0' if '0' in d else d for d in split('(0+)|(1+)', bin(n)[2:]) if d != '' and d != None), 2) # Chai Wah Wu, Nov 21 2018
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Leroy Quet, Dec 02 2009
EXTENSIONS
Extended by Ray Chandler, Dec 18 2009
a(11) onwards from Robert G. Wilson v and Reinhard Zumkeller, Dec 11 2009
STATUS
approved