OFFSET
1,2
COMMENTS
From Vladimir Shevelev, Dec 11 2014: (Start)
Or, sum of parts of the form 10...0 with nonnegative number of zeros in binary representation of n as the corresponding powers of 2. For example, n=50 in binary is a concatenation of parts (1)(100)(10). Then a(50)=1+4+2=7.
Every positive number k occurs a finite number of times, such that the position of the last appearance of k is 2^k-1.
Moreover, the number of times of appearances of k is the number of compositions of k into powers of 2, i.e., it is A023359(k), k>0. (End)
LINKS
Alois P. Heinz, Table of n, a(n) for n = 1..10000
FORMULA
Let, for k_1>k_2>...>k_r, n = 2^k_1 + 2^k_2 +...+ 2^k_r. Then a(n) = 2^(k_1-k_2-1) + 2^(k_2-k_3-1) + 2^(k_(r-1)-k_r-1) + 2^k_r. - Vladimir Shevelev, Dec 11 2013
EXAMPLE
52 in binary is 110100. Placing the +'s before every 1, we get +1+10+100, which is 1+2+4 = 7 in decimal. So a(52) = 7.
MAPLE
a:= proc(n) local l, s, i, j; l:= convert(n, base, 2); s:= 0; i:=1; for j from nops(l)-1 to 1 by -1 do if l[j]=0 then i:= i*2; else s:= s+i; i:= 1 fi od; s+i end: seq(a(n), n=1..150); # Alois P. Heinz, Jul 28 2009
Lton := proc(L) local i ; add(op(i, L)*2^(i-1), i=1..nops(L)) ; end: A162439 := proc(n) local a, lef, b2, ri ; a := 0 ; lef := 0; b2 := convert(n, base, 2) ; for ri from lef+1 do if op(ri, b2) = 1 then a := a+Lton([op(lef+1..ri, b2)]) ; lef := ri ; fi; if ri =nops(b2) then break; fi; od: a ; end: seq(A162439(n), n=1..100) ; # R. J. Mathar, Jul 30 2009
MATHEMATICA
a[n_] := FromDigits[#, 2]& /@ Split[IntegerDigits[n, 2] , #2==0&] // Total; Array[a, 100] (* Jean-François Alcover, Jan 07 2016 *)
CROSSREFS
KEYWORD
AUTHOR
Leroy Quet, Jul 03 2009
EXTENSIONS
More terms from Alois P. Heinz and R. J. Mathar, Jul 28 2009
STATUS
approved