A162439 Write down the binary representation of n. Partition the string which is this binary representation by placing a '+' just left of every 1. Add the resulting base 2 numbers. a(n) = decimal equivalent of this sum.
1, 2, 2, 4, 3, 3, 3, 8, 5, 4, 4, 5, 4, 4, 4, 16, 9, 6, 6, 6, 5, 5, 5, 9, 6, 5, 5, 6, 5, 5, 5, 32, 17, 10, 10, 8, 7, 7, 7, 10, 7, 6, 6, 7, 6, 6, 6, 17, 10, 7, 7, 7, 6, 6, 6, 10, 7, 6, 6, 7, 6, 6, 6, 64, 33, 18, 18, 12, 11, 11, 11, 12, 9, 8, 8, 9, 8, 8, 8, 18, 11, 8, 8, 8, 7, 7, 7, 11, 8, 7, 7, 8, 7, 7
Offset: 1
Examples
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.
Links
- Alois P. Heinz, Table of n, a(n) for n = 1..10000
Programs
-
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 *)
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
Extensions
More terms from Alois P. Heinz and R. J. Mathar, Jul 28 2009
Comments