OFFSET
0,3
COMMENTS
a(n) gives the sum of the values k for which 2^j*(k+1)-1 = n (A153733(n) gives the least value of k).
In general, for i >= 2, in the sequences of type "a(0) = 0; thereafter, a(i*n+1) = a(n)+i*n+1, otherwise a(n) = n.", a(n) gives the sum of the values k for which (i^j*((i-1)*(k+1)-i+2)-1)/(i-1) = n.
LINKS
Robert Israel, Table of n, a(n) for n = 0..10000
FORMULA
EXAMPLE
11 = 2^0*(11+1)-1 = 2^1*(5+1)-1 = 2^2*(2+1)-1, so a(11) = 11+5+2 = 18.
MAPLE
f:= proc(n) option remember; if n::even then n else n + procname((n-1)/2) fi end proc:
map(f, [$0..100]); # Robert Israel, Jul 04 2016
MATHEMATICA
a[0] = 0; a[n_] := a[n] = If[OddQ@ n, a[#] + 2 # + 1 &[(n - 1)/2], n]; Table[a@ n, {n, 0, 59}] (* Michael De Vlieger, Jul 04 2016 *)
PROG
(Python)
def A274593(n): return (((m:=~(n+1)&n)<<1)+1)*((n>>(k:=m.bit_length()))|1)-k-1 # Chai Wah Wu, Jul 13 2022
CROSSREFS
KEYWORD
nonn,look
AUTHOR
Gionata Neri, Jul 03 2016
STATUS
approved