OFFSET
0,2
MATHEMATICA
a[0] = 0; a[n_] := a[n] = If[Mod[n, 2] == 0, n/2, a[n - 1] + 2^(Floor[Log[2, 1 + n]])]; Table[a[n], {n, 0, 100}]
nxt[{n_, a_}]:={n+1, If[EvenQ[n+1], (n+1)/2, a+2^Floor[Log[2, n+2]]]}; Transpose[ NestList[ nxt, {0, 0}, 100]][[2]] (* Harvey P. Dale, Feb 26 2013 *)
PROG
(PARI) a(n)=n\2+if(n%2, 2^(log(n+1.5)\log(2))) \\ Charles R Greathouse IV, Jan 30 2012
CROSSREFS
KEYWORD
nonn,less,easy
AUTHOR
Roger L. Bagula and Gary W. Adamson, Sep 27 2008
STATUS
approved