OFFSET
0,4
LINKS
Robert Israel, Table of n, a(n) for n = 0..10000
FORMULA
G.f. g(x) satisfies g(x) = (1+x)*g(x^2)+x^2*(3*x+1)/(x^2-1)^2. - Robert Israel, Jan 20 2021
MAPLE
f:= proc(n) option remember;
if n::odd then procname(n-1)+n-1 else procname(n/2)+n/2 fi
end proc:
f(0):= 0:
map(f, [$0..100]); # Robert Israel, Jan 20 2021
MATHEMATICA
a[0] = 0; a[n_] := a[n] = If[OddQ[n], a[n - 1] + n - 1, a[n/2] + n/2]; Array[a, 100, 0] (* Amiram Eldar, Jul 28 2023 *)
PROG
(PARI) a(n)=if(n<1, 0, if(n%2, a(n-1)+n-1, a(n/2)+(n/2)))
CROSSREFS
KEYWORD
nonn
AUTHOR
Benoit Cloitre, Jun 23 2004
STATUS
approved